import { lib, game, ui, get, ai, _status } from "../../../noname.js";
export default {
    name: "DALF_reacgn",
    character: {
        db_reacgn_tobiichiorigami: ['female', 'reacgnling', 4, ['reacgn_juemietianshi', 'reacgn_rilun', 'reacgn_wangguan'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_honjounia: ['female', 'reacgnling', 3, ['reacgn_niegaoshentie', 'reacgn_weilaijizai', 'reacgn_zhihui'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_tokisakikurumi: ['female', 'reacgnling', 3, ['reacgn_kekedi', 'reacgn_canshizhicheng', 'reacgn_lixing'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_himekawayoshino: ['female', 'reacgnling', 3, ['reacgn_bingjiekuilei', 'reacgn_dongkai', 'reacgn_cibei'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_itsukakotori: ['female', 'reacgnling', 3, ['reacgn_zhuolanjiangui', 'reacgn_yuyi', 'reacgn_yanli'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_hoshimiyamukuro: ['female', 'reacgnling', 2, ['reacgn_fengjiezhu', 'reacgn_xinsheng', 'reacgn_qimei'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_kagaminonatsumi: ['female', 'reacgnling', 3, ['reacgn_yanzaomonv', 'reacgn_qianbianwanhuajing', 'reacgn_shengli'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_yamaikaguya: ['female', 'reacgnling', 4, ['reacgn_jufengqishi', 'reacgn_chuancizhe', 'reacgn_rongyao', 'acgndualside'],
            ['acgndualside:db_reacgn_yamaiyuzuru']
        ],
        db_reacgn_yamaiyuzuru: ['female', 'reacgnling', 4, ['reacgn_jufengqishi', 'reacgn_shufuzhe', 'reacgn_rongyao2', 'acgndualside'],
            ['acgndualside:db_reacgn_yamaikaguya']
        ],
        db_reacgn_izayoimiku: ['female', 'reacgnling', 3, ['reacgn_pojungeji', 'reacgn_kuangzou', 'reacgn_jichu'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_yatogamitooka: ['female', 'reacgnling', 4, ['reacgn_aosha', 'reacgn_zuizhongzhijian', 'reacgn_wangzuo'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        reacgn_itsukashidou: ['male', 'reacgnmeng', 4, ['reacgn_jiushu', 'reacgn_fengling'],
            []
        ],
        db_reacgn_yatogamitenka: ['female', 'reacgnling', '-2/4', ['reacgn_baonuegong', 'reacgn_zhongyanzhijian', 'reacgn_fuling_tenka'],
            ['doublegroup:reacgnmeng:reacgnling']
        ],
        db_reacgn_takamiyamio: ['female', 'shen', 1, ['reacgn_lunhuileyuan', 'reacgn_wanxiangshengtang', 'reacgn_wuxianzhizhi'],
            ['doublegroup:reacgnmeng:shen']
        ],
        reacgn_itsukashidou: ['male', 'reacgnmeng', 4, ['reacgn_jiushu', 'reacgn_fengling'],
            []
        ],

    },
    translate: {
        DALF_reacgn: "源初之灵",

        db_reacgn_tobiichiorigami: '鸢一折紙',
        reacgn_juemietianshi: '绝灭天使',
        reacgn_juemietianshi_info: '出牌阶段限一次，你可以将一张手牌置入你一个空置的装备栏并摸一张牌，若此牌不为装备牌，则横置之。',
        reacgn_rilun: '日轮',
        reacgn_rilun_info: '你可以将你装备区内横置的非装备牌如手牌使用或打出，你以此法使用的牌无距离和次数限制且此牌基础伤害改为X（X为你装备区内剩余横置牌数且至少为1）。',
        reacgn_wangguan: '救世之王冠',
        reacgn_wangguan_info: '锁定技，当你成为【杀】的目标后，你进行一次判定，若判定结果与你装备区内牌的花色存在相同，此【杀】无效。',

        db_reacgn_honjounia: '本条二亚',
        reacgn_niegaoshentie: '嗫告神帖',
        reacgn_niegaoshentie_info: '锁定技，你的初始手牌固定为等量的【影】；你的非【影】牌进入弃牌堆后，从游戏外将等量的【影】洗入牌堆。',
        reacgn_weilaijizai: '未来记载',
        reacgn_weilaijizai_info: '出牌阶段限一次，你可以展示一名角色的一张手牌，然后其选择一项：1、将此牌当做【杀】对你指定的另一名角色使用；2、弃置此牌并获得一张【影】。',
        reacgn_zhihui: '空望之智慧',
        reacgn_zhihui_info: '你可以将一张【影】当做一张你本回合未使用过的牌名的基本牌或普通锦囊牌使用或打出。',

        db_reacgn_tokisakikurumi: '时崎狂三',
        reacgn_kekedi: '刻刻帝',
        reacgn_kekedi_info: '一名角色回合开始时，你可以废除你的一个未被废除的装备栏并摸一张牌，然后你选择以下一个未选择过的阶段：1、判定阶段；2、摸牌阶段；3、出牌阶段；4、弃牌阶段；令其本回合跳过此阶段或其本回合首次该阶段结束后其执行一个额外的该阶段，然后若以上所有阶段均选择过，重置此技能。',
        reacgn_canshizhicheng: '喰时之城',
        reacgn_canshizhicheng_info: '游戏开始时，你废除所有装备栏。当你受到或造成伤害后，你可以恢复一个装备栏并摸一张牌。',
        reacgn_lixing: '轮回之理解',
        reacgn_lixing_info: '当一名其他角色处于濒死状态时，你可以废除X个装备栏并令其将体力回复至1点（X为本局游戏你发动此技能的次数）。',

        db_reacgn_himekawayoshino: '氷芽川四糸乃',
        reacgn_bingjiekuilei: '冰结傀儡',
        reacgn_bingjiekuilei_info: '出牌阶段各限一次：1.选择一名其他角色并指定一种花色，直到其下个回合结束，你与其此花色的手牌均视为冰【杀】；2.将一张♣手牌置入你一个空置的装备栏。',
        reacgn_dongkai: '冻铠',
        reacgn_dongkai_info: '锁定技，若你的防具栏有牌，则防止你受到的属性伤害；你使用你装备区内含有的花色的牌无次数限制。',
        reacgn_cibei: '空我之慈悲',
        reacgn_cibei_info: '你距离一以内的一名角色成为【杀】的唯一目标后，你可以将装备区内的一张牌交给【杀】的来源角色，令此【杀】目标获得一点护甲。',

        db_reacgn_itsukakotori: '五河琴里',
        reacgn_zhuolanjiangui: '灼烂歼鬼',
        reacgn_zhuolanjiangui_info: '转换技，出牌阶段限一次，你可以：斧、摸x张牌，“斧”状态下你使用牌无次数限制；炮、将X张牌置入牌堆底，视为使用一张无距离限制且伤害+1的火【杀】，“炮”状态下你使用牌无距离限制（X为你明置牌数）。',
        reacgn_yuyi: '羽衣',
        reacgn_yuyi_info: '每名角色回合结束时，你可以选择一项：1.明置一张牌；2.将一张明置牌置入牌堆底并回复一点体力。',
        reacgn_yanli: '破坏之杀欲',
        reacgn_yanli_info: '锁定技，每轮游戏开始时，你获得弃牌堆中所有的火焰伤害牌并明置；你的明置牌不计入手牌上限。',

        db_reacgn_hoshimiyamukuro: '星宮六喰',
        reacgn_fengjiezhu: "封解主",
        reacgn_fengjiezhu_info: '出牌阶段限一次，你可以选择一名角色并执行一项：<br>①<b>封</b>：令其一个技能失效，直到此后有X张牌进入弃牌堆；<br>②<b>解</b>：你弃置其区域内的X张牌。<br>③<b>闭</b>：其不能使用或打出牌，直到此后有X张牌进入弃牌堆；<br>④<b>开</b>：令其摸X张牌。<br>(X为你的体力上限）。',
        reacgn_xinsheng: "新生",
        reacgn_xinsheng_info: "觉醒技，准备阶段，若你的〖封解主〗中所有选项失效，你可以恢复其中任意个选项，然后你减少等量体力上限并摸等量张牌。",
        reacgn_qimei: "遗落之凄美",
        reacgn_qimei_info: "当你受到伤害时，你可以令你的〖封解主〗中一个未失效的选项失效并防止此伤害，然后你增加1点体力上限。",

        db_reacgn_kagaminonatsumi: '镜野七罪',
        reacgn_yanzaomonv: '赝造魔女',
        reacgn_yanzaomonv_info: '每轮限一次，一名角色的回合开始时，你可以选择一名未以此法选择过的一名其他角色的一个技能，你获得此技能直到此回合结束。',
        reacgn_qianbianwanhuajing: '千变万化镜',
        reacgn_qianbianwanhuajing_info: '转换技，出牌阶段限一次，你可以：阳、选择一名角色的一张手牌，令其将此牌当做你指定牌名的装备牌使用；阴、选择一名角色装备区内的一张牌，令其将此牌当做你指定牌名的一张基本牌或普通锦囊牌使用。',
        reacgn_shengli: '非欲之胜利',
        reacgn_shengli_info: '其他角色的准备阶段，若其装备区内存在与你装备区内同牌名的装备牌，你可以发动一次〖千变万化镜〗。',

        db_reacgn_yamaikaguya: '八舞耶倶矢',
        db_reacgn_yamaiyuzuru: '八舞夕弦',
        reacgn_jufengqishi: '飓风骑士',
        reacgn_jufengqishi_info: '锁定技，每当你使用一张与你使用的上一张类别相同的牌时，你摸一张牌，否则你弃置一张牌且此技能失效直到本回合结束。',
        reacgn_shufuzhe: '束缚者',
        reacgn_shufuzhe_info: '出牌阶段限一次，你可以将所有手牌当做【铁索连环】使用，结算后你可以弃置所有处于横置状态的角色各一张牌，然后你可以翻面，',
        reacgn_chuancizhe: '穿刺者',
        reacgn_chuancizhe_info: '出牌阶段限一次，你可以将所有手牌当做一张可以指定至多X名角色为目标的任意属性【杀】使用（X为你转化的牌数），结算完成后，你可以翻面。',
        reacgn_rongyao: '登程之荣耀',
        reacgn_rongyao_info: '当你翻至此面时，你可以摸两张牌。',
        reacgn_rongyao2: '登程之荣耀',
        reacgn_rongyao2_info: '当你翻至此面时，你可以摸两张牌。',

        db_reacgn_izayoimiku: '诱宵美九',
        reacgn_pojungeji: "破军歌姬",
        reacgn_pojungeji_info: "锁定技，你的牌因使用而进入弃牌堆后，你可以将此牌置于你的武将牌上，称为“音”，然后若此牌与你武将牌上的“音”达成边缘点数相连，则你摸一张牌。",
        reacgn_kuangzou: '狂奏',
        reacgn_kuangzou_info: "结束阶段，你可以移去三张“音”，若这些“音”满足以下条件，则你可以依次执行任意项：<br><b><span style='color:#DC143C'>进行曲</span></b>：类别相同，你令至多名角色依次各摸一张牌，然后这些角色可以依次使用一张牌；<br><b><span style='color:#FF00FF'>圆舞曲</span></b>：颜色相同，弃置至多三名角色共计至多三张牌。<br><b><span  style='color:#B15BFF'>镇魂曲</span></b>：点数相同，你令至多三名角色各回复1点体力。",
        reacgn_jichu: "不羁之原则",
        reacgn_jichu_info: "锁定技，若你在一个阶段内“狂奏”所有分支均执行，则你选择一名其他角色A，你展示其所有手牌并指定另一名角色B，令A将其手牌中所有可以对B使用的牌依次对B使用之。",

        db_reacgn_yatogamitooka: '夜刀神十香',
        reacgn_aosha: '鏖杀公',
        reacgn_aosha_info: '当你使用【杀】或装备牌结算后，你可以亮出牌堆顶的一张牌，若此牌为【杀】或装备牌，则你可以使用此之（以此法使用的牌不计入次数限制）。',
        reacgn_zuizhongzhijian: '最终之剑',
        reacgn_zuizhongzhijian_info: '限定技，出牌阶段，你可以失去技能〖最后的王座〗，若如此做，本回合内你使用【杀】无次数限制，本回合结束阶段，你可以将你装备区内的所有装备牌当做一张无距离限制且伤害为X的【杀】使用（X为转化的牌数）。',
        reacgn_wangzuo: '最后的王座',
        reacgn_wangzuo_info: '其他角色的准备阶段，你可以将你装备区内的一张牌当做【杀】对其使用。',

        db_reacgn_yatogamitenka: '夜刀神天香',
        reacgn_baonuegong: '暴虐公',
        reacgn_baonuegong_info: '锁定技，你使用【杀】结算完成后，你将此【杀】在弃牌堆中的所有实体牌置入你的武将牌上称为“武装”并展示牌堆顶的一张牌，若该牌与你使用的【杀】颜色相同，你将该牌当做【杀】使用之。',
        reacgn_zhongyanzhijian: '终焉之剑',
        reacgn_zhongyanzhijian_info: '限定技，出牌阶段，你可以将所有“武装”牌当做一张不计入次数的暗【杀】使用，此【杀】造成伤害前，伤害改为此【杀】实体牌张数。',
        reacgn_fuling_tenka: '负灵',
        reacgn_fuling_tenka_info: '锁定技，永恒技，若你的体力值不大于0，你不会死亡。你只有摸牌阶段和出牌阶段。你受到的伤害改为恢复等量的体力值。你的体力值为正数时，你将该武将牌替换为〖夜刀神十香〗。',

        db_reacgn_takamiyamio: '崇宫澪',
        reacgn_lunhuileyuan: '轮回乐园',
        reacgn_lunhuileyuan_info: '①有牌因弃置进入弃牌堆后，置入你的武将牌上称为“乐园”。<br>②当一名角色使用一张牌结算后，若你的武将牌上有同名牌，你可以令你与其各从你的武将牌上随机获得一张牌。<br>③你的手牌上限+X(X为你武将牌上的“乐园”数)。',
        reacgn_wanxiangshengtang: '万象圣堂',
        reacgn_wanxiangshengtang_info: '你造成伤害后，你可以摸两张牌并将一张牌置于其武将牌上称为“乐园”<br>其他有“乐园”的角色回合开始时，你弃置其X张牌（X为你损失体力值），然后其对你造成1点伤害并移去其所有“乐园”。',
        reacgn_wuxianzhizhi: '无限之质',
        reacgn_wuxianzhizhi_info: '当你进入濒死状态时，若当前回合角色不为“约战”角色，你可以增加1点体力上限，并将体力值回复至上限，然后你选择一个未登场的“约战”角色的武将牌，替换其一个武将牌。',

        reacgn_itsukashidou: '五河士道',
        reacgn_jiushu: "救赎",
        reacgn_jiushu_info: "出牌阶段限一次，你可以弃置任意张牌或失去任意点体力，然后令一名已受伤的其他角色回复等量的体力。<br>你造成伤害时，你可以将此伤害改为令其回复等量体力。<br>你令其他角色回复体力后，若其体力值小于你，则你可以摸等量的牌或回复等量的体力。",
        reacgn_fengling: "封灵",
        reacgn_fengling_info: "锁定技，当你因“救赎”令其他角色将体力值回复至上限后，你获得其武将牌上第一个技能，直到场上角色数减少。",
    },
    skill: {
        //装备横置
        _reacgnequipLink: {
            charlotte: true,
            trigger: {
                player: ["loseAfter", "reacgnequipLinkAfter", "restoreReacgnequipLinkAfter"],
                global: ["equipAfter", "addJudgeAfter", "gainAfter", "loseAsyncAfter", "addToExpansionAfter"],
            },
            forced: true,
            popup: false,
            firstDo: true,
            filter(event, player) {
                if (['reacgnequipLink', 'restoreReacgnequipLink'].includes(event.name)) return true;
                if (event.name == 'equip' && event.player == player && get.is.reacgnequipLinkCard(event.card, true)) return true;
                const evt = event.getl(player);
                return evt && evt.player == player && evt.es && evt.es.some(card => get.is.reacgnequipLinkCard(card, true));
            },
            getSkills(player) {
                return player.getCards('e', card => get.is.reacgnequipLinkCard(card, true)).reduce((list, card) => {
                    const info = get.info(card);
                    if (info && info.skills) return list.addArray(info.skills);
                    return list;
                }, []);
            },
            async content(event, trigger, player) {
                player.enableSkill('_reacgnequipLink');
                player.disableSkill('_reacgnequipLink', lib.skill._reacgnequipLink.getSkills(player));
            },
            init(player, skill) {
                player.disableSkill(skill, lib.skill._reacgnequipLink.getSkills(player));
            },
            onremove(player, skill) {
                player.enableSkill(skill);
            },
            mod: {
                attackFrom(from, to, distance) {
                    const cards = from.getCards('e', card => {
                        return get.is.reacgnequipLinkCard(card, true);
                    });
                    if (!cards.length) return;
                    const num = cards.filter(card => {
                        return get.info(card) && get.info(card).distance && get.info(card).distance.attackFrom;
                    }).reduce((p, c) => p + get.info(c).distance.attackFrom, 0);
                    return distance - num;
                },
                globalTo(from, to, distance) {
                    const cards = to.getCards('e', card => {
                        return get.is.reacgnequipLinkCard(card, true);
                    });
                    if (!cards.length) return;
                    const num = cards.filter(card => {
                        return get.info(card) && get.info(card).distance && get.info(card).distance.globalTo;
                    }).reduce((p, c) => p + get.info(c).distance.globalTo, 0);
                    return distance - num;
                },
                globalFrom(from, to, distance) {
                    const cards = from.getCards('e', card => {
                        return get.is.reacgnequipLinkCard(card, true);
                    });
                    if (!cards.length) return;
                    const num = cards.filter(card => {
                        return get.info(card) && get.info(card).distance && get.info(card).distance.globalFrom;
                    }).reduce((p, c) => p + get.info(c).distance.globalFrom, 0);
                    return distance - num;
                },
            },
            subSkill: {
                remove: {
                    trigger: {
                        player: "loseBegin",
                    },
                    forceDie: true,
                    charlotte: true,
                    onremove: true,
                    forced: true,
                    popup: false,
                    filter(event, player) {
                        return event.cards.some(card => get.is.reacgnequipLinkCard(card));
                    },
                    async content(event, trigger, player) {
                        const cards = trigger.cards.filter(card => get.is.reacgnequipLinkCard(card));
                        for (var card of cards) {
                            card.storage.reacgnequipLink = false;
                        }
                        if (cards.length) game.log(cards, '解除', '#g横置', '状态');
                    },
                },
            },
        },
        //双面武将
        acgndualside: {
            charlotte: true,
            getdualside(player, unseen) {
                const list = [];
                if (unseen || !player.isUnseen(0)) {
                    let info = lib.character[player.name1];
                    if (info && info.trashBin) list.addArray(info.trashBin);
                }
                if (player.name2 && (unseen || !player.isUnseen(1))) {
                    let info = lib.character[player.name2];
                    if (info && info.trashBin) list.addArray(info.trashBin);
                }
                return list.filter(info => typeof info === 'string' && info.startsWith('acgndualside:'))
                    .map(info => info.slice(13));
            },
            group: ["acgndualside_init", "acgndualside_turn"],
            subSkill: {
                init: {
                    trigger: {
                        global: "gameStart",
                        player: "enterGame",
                    },
                    silent: true,
                    filter(event, player) {
                        return (event.name != "phase" || game.phaseNumber == 0);
                    },
                    async content(event, trigger, player) {
                        var side = get.info("acgndualside").getdualside(player);
                        if (side && side.length) {
                            player.storage.acgndualside = side[0];
                        }
                        var cfg = player.storage.acgndualside;
                        player.markSkillCharacter("acgndualside", { name: cfg }, "背面");
                    },
                },
                turn: {
                    trigger: {
                        player: "turnOverBefore",
                    },
                    silent: true,
                    filter(event, player) {
                        return player.storage.acgndualside;
                    },
                    async content(event, trigger, player) {
                        trigger.cancel();
                        var cfg = player.storage.acgndualside;
                        await player.reinitCharacter(player.name1, cfg);
                        var side = get.info("acgndualside").getdualside(player);
                        if (side && side.length) {
                            player.storage.acgndualside = side[0];
                            cfg = player.storage.acgndualside;
                            player.unmarkSkill("acgndualside");
                            player.markSkillCharacter("acgndualside", { name: cfg }, "背面");
                        }
                    },
                },
            },
        },

        //鸢一折紙
        reacgn_juemietianshi: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            enable: "phaseUse",
            usable: 1,
            filter(event, player) {
                if (!player.countCards("h")) return false;
                for (let i = 0; i <= 5; i++) {
                    if (player.hasEmptySlot(i)) return true;
                }
                return false;
            },
            chooseButton: {
                dialog(event, player) {
                    return ui.create.dialog("###绝灭###你可将一张手牌置于你的空置装备栏并摸一张牌");
                },
                chooseControl(event, player) {
                    const choices = [];
                    for (let i = 0; i <= 5; i++) {
                        if (player.hasEmptySlot(i)) choices.push(`equip${i}`);
                    }
                    choices.push("cancel2");
                    return choices;
                },

                backup(result, player) {
                    return {
                        slot: result.control,
                        filterCard: true,
                        ai1(card) {
                            return get.value(card);
                        },
                        discard: false,
                        lose: false,
                        delay: false,
                        prepare: "throw",
                        async content(event, trigger, player) {
                            const card = get.autoViewAs(event.cards[0]);
                            card.subtypes = [lib.skill.reacgn_juemietianshi_backup.slot];
                            await player.equip(card);
                            await player.draw();
                            if (get.type(card) != 'equip') player.reacgnequipLink(event.cards);
                        },
                    }
                },
                prompt(result, player) {
                    return `选择一张手牌置入${get.translation(result.control)}栏`;
                },
            },
            ai: {
                order: 10,
                result: {
                    player: 1,
                },
            },
            subSkill: {
                backup: {},
            },
        },
        reacgn_rilun: {
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                player: "reacgnequipLinkEnd",
            },
            forced: true,
            locked: false,
            filter(event, player) {
                return event.cards.length;
            },
            async content(event, trigger, player) {
                var cards = player.getCards('e', function (card) {
                    return card.storage.reacgnequipLink && !player.getCards('s', cardx => {
                        return cardx.hasGaintag('reacgn_rilun');
                    }).map(i => i._cardid).includes(card.cardid);
                });
                var cardsx = cards.map(card => {
                    var cardx = ui.create.card();
                    cardx.init(get.cardInfo(card));
                    cardx._cardid = card.cardid;
                    return cardx;
                });
                player.directgains(cardsx, null, "reacgn_rilun");
                player.addSkill("reacgn_rilun_in");
            },
            group: "reacgn_rilun_effect",
            subSkill: {
                in: {
                    trigger: {
                        player: "loseEnd",
                        global: ["equipEnd", "addJudgeEnd", "gainEnd", "loseAsyncEnd", "addToExpansionEnd"],
                    },
                    forced: true,
                    locked: false,
                    silent: true,
                    filter(event, player) {
                        var idList = player.getCards("s", card => card.hasGaintag("reacgn_rilun")).map(i => i._cardid);
                        return (
                            event.getl(player) &&
                            event.getl(player).cards2.some(card => {
                                return idList.includes(card.cardid);
                            })
                        );
                    },
                    async content(event, trigger, player) {
                        var cards2;
                        var idList = trigger.getl(player).cards2.map(i => i.cardid);
                        cards2 = player.getCards("s", card => {
                            return card.hasGaintag("reacgn_rilun") && idList.includes(card._cardid);
                        });
                        if (player.isOnline2()) {
                            player.send(
                                function (cards, player) {
                                    cards.forEach(i => i.delete());
                                    if (player == game.me) ui.updatehl();
                                },
                                cards2,
                                player
                            );
                        }
                        cards2.forEach(i => i.delete());
                        if (player == game.me) ui.updatehl();
                    },
                    onremove(player) {
                        var cards2 = player.getCards("s", card => {
                            return card.hasGaintag("reacgn_rilun");
                        });
                        if (player.isOnline2()) {
                            player.send(
                                function (cards, player) {
                                    cards.forEach(i => i.delete());
                                    if (player == game.me) ui.updatehl();
                                },
                                cards2,
                                player
                            );
                        }
                        cards2.forEach(i => i.delete());
                        if (player == game.me) ui.updatehl();
                    },
                    group: ["reacgn_rilun_use", "reacgn_rilun_lose"],
                },
                use: {
                    trigger: {
                        player: ["useCardBefore", "respondBefore"],
                    },
                    charlotte: true,
                    forced: true,
                    popup: false,
                    firstDo: true,
                    filter(event, player) {
                        var cards = player.getCards("s", card => card.hasGaintag("reacgn_rilun") && card._cardid);
                        return (
                            event.cards &&
                            event.cards.some(card => {
                                return cards.includes(card);
                            })
                        );
                    },
                    content() {
                        var idList = player.getCards("s", card => card.hasGaintag("reacgn_rilun")).map(i => i._cardid);
                        var cards = player.getCards('e', function (card) {
                            return card.storage.reacgnequipLink && idList.includes(card.cardid);
                        });
                        var cards2 = [];
                        for (var card of trigger.cards) {
                            var cardx = cards.find(cardx => cardx.cardid == card._cardid);
                            if (cardx) cards2.push(cardx);
                        }
                        var cards3 = trigger.cards.slice();
                        trigger.cards = cards2;
                        trigger.card.cards = cards2;
                        if (player.isOnline2()) {
                            player.send(
                                function (cards, player) {
                                    cards.forEach(i => i.delete());
                                    if (player == game.me) ui.updatehl();
                                },
                                cards3,
                                player
                            );
                        }
                        cards3.forEach(i => i.delete());
                        if (player == game.me) ui.updatehl();
                    },
                },
                lose: {
                    trigger: {
                        global: ["loseEnd", "equipEnd", "addJudgeEnd", "gainEnd", "loseAsyncEnd", "addToExpansionEnd", "cardsGotoOrderingBegin"],
                    },
                    charlotte: true,
                    forced: true,
                    popup: false,
                    firstDo: true,
                    filter(event, player) {
                        var idList = player.getCards("s", card => card.hasGaintag("reacgn_rilun")).map(i => i._cardid);
                        return (
                            event.cards &&
                            event.cards.some(card => {
                                return idList.includes(card.cardid);
                            })
                        );
                    },
                    content() {
                        var cards2;
                        var idList = player.getCards("e", card => card.storage.reacgnequipLink).map(i => i.cardid);
                        cards2 = player.getCards("s", card => {
                            return card.hasGaintag("reacgn_rilun") && idList.includes(card._cardid);
                        });
                        if (player.isOnline2()) {
                            player.send(
                                function (cards, player) {
                                    cards.forEach(i => i.delete());
                                    if (player == game.me) ui.updatehl();
                                },
                                cards2,
                                player
                            );
                        }
                        cards2.forEach(i => i.delete());
                        if (player == game.me) ui.updatehl();
                    },
                },
                effect: {
                    trigger: {
                        player: "useCard",
                    },
                    forced: true,
                    locked: false,
                    filter(event, player) {
                        return event.cards.some(card => get.is.reacgnequipLinkCard(card));
                    },
                    async content(event, trigger, player) {
                        trigger.baseDamage = Math.max(1, player.countCards('e', card => get.is.reacgnequipLinkCard(card)));
                    },
                },
            },
            mod: {
                cardUsable(card, player, num) {
                    if (!card.cards) return;
                    for (let i of card.cards) {
                        if (i.hasGaintag("reacgn_rilun")) return Infinity;
                    }
                },
                targetInRange(card, player, target) {
                    if (!card.cards) return;
                    for (let i of card.cards) {
                        if (i.hasGaintag("reacgn_rilun")) return true;
                    }
                },
            },
        },
        reacgn_wangguan: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                target: "useCardToTargeted",
            },
            forced: true,
            filter(event, player) {
                if (!player.countCards('e')) return false;
                return event.card.name == 'sha';
            },
            async content(event, trigger, player) {
                const suits = player.getCards('e')
                    .map(card => get.suit(card));
                const judgeEvent = player.judge(card => {
                    if (suits.includes(get.suit(card))) return 2;
                    return -1;
                });
                judgeEvent.judge2 = result => result.bool;
                const {
                    result: { bool },
                } = await judgeEvent;
                if (bool) {
                    trigger.getParent().excluded.add(player);
                    game.log(trigger.card, '对', player, '无效');
                }
            },
            ai: {
                effect: {
                    target(card, player, target) {
                        if (typeof card !== "object") return;
                        if (!target.countCards('e')) return;
                        const suits = target.getCards('e')
                            .map(card => get.suit(card));
                        if (card.name == "sha" && suits.length >= lib.suit.length) return "zeroplayertarget";
                    },
                },
            },
        },
        //本条二亚
        reacgn_niegaoshentie: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                player: "loseAfter",
                global: "loseAsyncAfter",
            },
            forced: true,
            filter(event, player) {
                var evt = event.getl(player);
                for (var i of evt.cards2) {
                    if (get.position(i) == "d" && get.name(i, false) != 'ying') {
                        return true;
                    }
                }
                return false;
            },
            async content(event, trigger, player) {
                var cards = [],
                    cards2 = trigger.getl(player).cards2;
                for (var i of cards2) {
                    if (get.position(i) == "d" && get.name(i, false) != 'ying') cards.push(i);
                }
                game.broadcastAll(function () {
                    lib.inpile.add("ying");
                });
                if (cards.length) {
                    const yingCards = lib.card.ying.getYing(cards.length);
                    game.cardsGotoPile(yingCards, () => {
                        return ui.cardPile.childNodes[get.rand(0, ui.cardPile.childNodes.length - 1)];
                    });
                }
            },
            group: "reacgn_niegaoshentie_init",
            subSkill: {
                init: {
                    trigger: {
                        global: "phaseBefore",
                        player: "enterGame",
                    },
                    forced: true,
                    filter(event, player) {
                        return (event.name != "phase" || game.phaseNumber == 0);
                    },
                    async content(event, trigger, player) {
                        const cards = player.getCards('h');
                        if (cards.length) {
                            await player.loseToDiscardpile(cards, ui.cardPile, "blank")
                                .set("log", false)
                                .set('insert_index', () => {
                                    return ui.cardPile.childNodes[get.rand(0, ui.cardPile.childNodes.length - 1)];
                                });
                            await player.gain(lib.card.ying.getYing(cards.length), 'gain2');
                        }
                    },
                },
            },
        },
        reacgn_weilaijizai: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            enable: "phaseUse",
            usable: 1,
            filterTarget(card, player, target) {
                return target.countCards('h');
            },
            async content(event, trigger, player) {
                const target = event.targets[0];
                if (target.countCards('h')) {
                    const { result: { bool, links } } = await player.choosePlayerCard(target, "h", true);
                    if (bool) {
                        const card = links[0];
                        if (
                            game.hasPlayer(function (current) {
                                return current != player && current != target;
                            })
                        ) {
                            const { result } = await player
                                .chooseTarget(true, "选择" + get.translation(target) + "使用【杀】的目标", function (card, player, target) {
                                    return target != player && target != _status.event.source;
                                })
                                .set("source", target)
                                .set("ai", function (target) {
                                    var evt = _status.event;
                                    return get.effect(target, { name: "sha" }, evt.source, evt.player);
                                });
                            if (result.bool) {
                                const { result: { bool } } = await target.chooseUseTarget({ name: "sha" }, [card], result.targets)
                                    .set('prompt', `将${get.translation(card)}当做【杀】对${get.translation(result.targets[0])}使用，否则你弃置此牌`)
                                if (!bool) {
                                    await target.discard(card);
                                    await target.gain(lib.card.ying.getYing(), 'gain2');
                                }
                            }
                        } else {
                            await target.discard(card);
                            await player.gain(lib.card.ying.getYing(), 'gain2');
                        }
                    }
                }
            },
            ai: {
                order: 1,
                result: {
                    target(player, target) {
                        if (target.getCards('h').every(card => get.name(card, target) == 'ying')) return 0;
                        return -1;
                    },
                },
            },
        },
        reacgn_zhihui: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            enable: ["chooseToUse", "chooseToRespond"],
            filter(event, player) {
                if (!player.countCards('hs', { name: 'ying' })) return false;
                return get.inpileVCardList(info => {
                    const name = info[2];
                    if (get.type(name) != "basic" && get.type(name) != "trick") return false;
                    return !(event.reacgn_zhihui || []).includes(name);
                })
                    .some(card => event.filterCard({ name: card[2], nature: card[3] }, player, event));
            },
            onChooseToUse(event) {
                if (!game.online && !event.reacgn_zhihui) {
                    const player = event.player;
                    event.set("reacgn_zhihui", get.info("reacgn_zhihui").getUsed(player));
                }
            },
            chooseButton: {
                dialog(event, player) {
                    const list = get
                        .inpileVCardList(info => {
                            const name = info[2];
                            if (get.type(name) != "basic" && get.type(name) != "trick") return false;
                            return !(event.reacgn_zhihui || []).includes(name);
                        })
                        .filter(card => event.filterCard({ name: card[2], nature: card[3] }, player, event));
                    const dialog = ui.create.dialog('空望之智慧', [list, 'vcard']);
                    dialog.direct = true;
                    return dialog;
                },
                check(button) {
                    if (get.event().getParent().type != "phase") return 1;
                    return get.event("player").getUseValue({
                        name: button.link[2],
                        nature: button.link[3],
                    });
                },
                backup(links, player) {
                    return {
                        audio: "reacgn_zhihui",
                        viewAs: {
                            name: links[0][2],
                            nature: links[0][3],
                        },
                        filterCard(card) {
                            return get.itemtype(card) == "card" && get.name(card) == "ying";
                        },
                        ai1(card) {
                            return 1;
                        },
                        selectCard: 1,
                        position: "hs",
                    }
                },
                prompt(links, player) {
                    return '将一张【影】当做' + (get.translation(links[0][3]) || '') + get.translation(links[0][2]) + '使用或打出';
                },
            },
            getUsed: player => player.getHistory("useCard", evt => ["basic", "trick"].includes(get.type(evt.card, null, false)))
                .map(evt => get.name(evt.card))
                .toUniqued(),
            hiddenCard(player, name) {
                if (!lib.inpile.includes(name)) return false;
                const type = get.type(name);
                return (type == 'basic' || type == 'trick') && !player.hasHistory('useCard', evt => evt.card.name == name);
            },
            ai: {
                respondSha: true,
                respondShan: true,
                skillTagFilter(player, tag, arg) {
                    const name = tag == "respondSha" ? "sha" : "shan";
                    return get.info("reacgn_zhihui").hiddenCard(player, name);
                },
                order(item, player) {
                    if (player && get.event().type == "phase") {
                        let list = get
                            .inpileVCardList(info => {
                                const name = info[2];
                                if (get.type(name) != "basic" && get.type(name) != "trick") return false;
                                return !get.info("reacgn_zhihui").getUsed(player).includes(name);
                            })
                            .map(card => {
                                return { name: card[2], nature: card[3] };
                            })
                            .filter(card => player.getUseValue(card, true, true) > 0);
                        if (!list.length) return 0;
                        list.sort((a, b) => (player.getUseValue(b, true, true) || 0) - (player.getUseValue(a, true, true) || 0));
                        return get.order(list[0], player) * 0.99;
                    }
                    return 0.001;
                },
                result: {
                    player(player) {
                        if (_status.event.dying) return get.attitude(player, _status.event.dying);
                        return 1;
                    },
                },
            },
        },
        //时崎狂三
        reacgn_kekedi: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                global: "phaseBegin",
            },
            filter(event, player) {
                return player.hasEnabledSlot();
            },
            logTarget: 'player',
            async content(event, trigger, player) {
                await player.chooseToDisable()
                    .set("ai", function (event, player, list) {
                        var list = [3, 5, 4, 1, 2];
                        for (var i of list) {
                            if (player.hasEnabledSlot(i)) {
                                var card = player.getEquip(i);
                                if (!card || player.hasEmptySlot(i)) return "equip" + i;
                                if (get.value(card, player) <= 0) return "equip" + i;
                            }
                        }
                        return list.randomGet();
                    });
                await player.draw();
                const { result: { bool, links } } = await player.chooseButton([`${get.prompt2(event.name)}`, [
                    [
                        ["phaseJudge", "　　　⒈判定阶段　　　"],
                        ["phaseDraw", "　　　⒉摸牌阶段　　　"],
                    ],
                    "tdnodes",
                ],
                [
                    [
                        ["phaseUse", "　　　⒊出牌阶段　　　"],
                        ["phaseDiscard", "　　　⒋弃牌阶段　　　"],
                    ],
                    "tdnodes",
                ],
                [
                    [
                        [0, "　　　跳过阶段　　　"],
                        [1, "　　　额外阶段　　　"],
                    ],
                    "tdnodes",
                ]
                ])
                    .set('selectButton', 2)
                    .set('filterButton', button => {
                        const player = get.player(),
                            type = typeof button.link;
                        if (player.getStorage("reacgn_kekedi_record").includes(button.link)) return false;
                        if (ui.selected.buttons.length && type == typeof ui.selected.buttons[0].link) return false;
                        return true;
                    })
                    .set('ai', button => {
                        if (!ui.selected.buttons.length) {
                            switch (button.link) {
                                case "phaseJudge":
                                    {
                                        return 1;
                                    }
                                case "phaseDraw":
                                    {
                                        return 1.1;
                                    }
                                case "phaseUse":
                                    {
                                        return 1;
                                    }
                                case "phaseDiscard":
                                    {
                                        return 1.2;
                                    }
                                default:
                                    return 0;
                            }
                        } else {
                            switch (ui.selected.buttons[0].link) {
                                case "phaseJudge":
                                    {
                                        return 1;
                                    }
                                case "phaseDraw":
                                    {
                                        return 1.1;
                                    }
                                case "phaseUse":
                                    {
                                        return 1;
                                    }
                                case "phaseDiscard":
                                    {
                                        return 1.2;
                                    }
                                default:
                                    return 0;
                            }
                        }
                    })
                if (bool) {
                    if (typeof links[0] != "string") links.reverse();
                    const phase = links[0],
                        choice = links[1],
                        skill = `reacgn_kekedi_${phase}${choice ? '_out' : '_in'}`;
                    if (!lib.skill[skill]) {
                        game.broadcastAll((skill, triggername, content) => {
                            lib.translate[skill] = '刻帝';
                            if (content) {
                                lib.skill[skill] = {
                                    trigger: {
                                        player: `${triggername}After`,
                                    },
                                    forced: true,
                                    charlotte: true,
                                    async content(event, trigger, player) {
                                        var next = player[trigger.name]();
                                        event.next.remove(next);
                                        trigger.getParent().next.push(next);
                                        player.removeSkill(event.name);
                                    },
                                    mark: true,
                                    intro: {
                                        content: `本回合首个${get.translation(triggername)}结束后，你执行一个额外的${get.translation(triggername)}。`,
                                    },
                                }
                            } else {
                                lib.skill[skill] = {
                                    trigger: {
                                        player: `${triggername}Before`,
                                    },
                                    forced: true,
                                    charlotte: true,
                                    async content(event, trigger, player) {
                                        trigger.cancel();
                                    },
                                    mark: true,
                                    intro: {
                                        content: `本回合跳过你的${get.translation(triggername)}。`,
                                    },
                                }
                            }
                        }, skill, phase, choice)
                    }
                    trigger.player.addTempSkill(skill);
                    player.markAuto("reacgn_kekedi_record", [links[0]]);
                    if (player.getStorage("reacgn_kekedi_record").length == 4) {
                        game.log(player, '重置了', `#g【${get.translation(event.name)}】`);
                        delete player.storage.reacgn_kekedi_record;
                    }
                }
            },
        },
        reacgn_canshizhicheng: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                source: "damageSource",
                player: "damageEnd",
            },
            frequent: true,
            filter(event, player) {
                return player.hasDisabledSlot();
            },
            prompt2: `当你受到或造成伤害后，你可以恢复一个装备栏并摸一张牌。`,
            async content(event, trigger, player) {
                await player.chooseToEnable()
                    .set("ai", () => {
                        var player = get.player();
                        var list = [2, 5, 1, 3, 4];
                        for (var i of list) {
                            if (player.hasDisabledSlot(i)) return "equip" + i;
                        }
                    });
                player.draw();
            },
            group: "reacgn_canshizhicheng_init",
            subSkill: {
                init: {
                    trigger: {
                        player: "enterGame",
                        global: "phaseBefore",
                    },
                    forced: true,
                    locked: false,
                    filter(event, player) {
                        return (event.name != "phase" || game.phaseNumber == 0) && player.hasEnabledSlot();
                    },
                    async content(event, trigger, player) {
                        var list = [];
                        for (var i = 1; i < 6; i++) {
                            for (var j = 0; j < player.countEnabledSlot(i); j++) {
                                list.push(i);
                            }
                        }
                        player.disableEquip(list);
                    },
                },
            },
        },
        reacgn_lixing: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            enable: "chooseToUse",
            filter(event, player) {
                if (event.type != 'dying') return false;
                if (event.dying == player) return false;
                return event.dying && player.countEnabledSlot() >= player.getAllHistory('useSkill', evt => evt.skill == 'reacgn_lixing_backup').length;
            },
            chooseButton: {
                dialog(event, player) {
                    let dialog = ui.create.dialog("###" + get.translation("reacgn_lixing") + "###" + lib.translate.reacgn_lixing_info, "hidden");
                    let equips = [];
                    for (let i = 1; i < 6; i++) {
                        if (!player.hasEnabledSlot(i)) continue;
                        for (let j = 1; j <= player.countEnabledSlot(i); j++) {
                            equips.push(["equip" + i, get.translation("equip" + i)]);
                        }
                    }
                    if (equips.length > 0) dialog.add([equips, "tdnodes"]);
                    return dialog;
                },
                check(button) {
                    const player = get.event().player;
                    if (player.countCards("e") <= 3 && _status.currentPhase === player && ((player.storage.counttrigger || {}).olchishi || 0) <= 0) {
                        if (
                            player
                                .getCards("e")
                                .slice()
                                .map(i => get.subtype(i))
                                .includes(button.link)
                        )
                            return 10;
                    }
                    if (
                        ui.selected.buttons.length >=
                        Math.max(
                            ...game.filterPlayer().map(target => {
                                let max = 0;
                                if (get.attitude(player, target) > 0 && (target == player || target.hasDisabledSlot())) max++;
                                if (get.recoverEffect(target, player, player) > 0) max++;
                                if (
                                    target.countCards("h") > 0 &&
                                    target
                                        .getCards("h", card => {
                                            return lib.filter.cardDiscardable(card, target);
                                        })
                                        .reduce((sum, card) => {
                                            return sum + get.value(card, target);
                                        }, 0) <=
                                    get.effect(target, { name: "draw" }, player, player) * 4
                                )
                                    max++;
                                return max;
                            })
                        )
                    )
                        return 0;
                    return [2, 1, 4, 3, 5].indexOf(parseInt(button.link.slice("equip".length))) + 1;
                },
                select() {
                    const player = get.player(),
                        num = player.getAllHistory('useSkill', evt => evt.skill == 'reacgn_lixing_backup').length;
                    return num + 1;
                },
                backup(links, player) {
                    return {
                        types: links.slice().sort((a, b) => parseInt(a.slice("equip".length)) - parseInt(b.slice("equip".length))),
                        filterTarget(card, player, target) {
                            return target != player && target == _status.event.dying;
                        },
                        selectTarget: -1,
                        multitarget: true,
                        async content(event, trigger, player) {
                            const target = event.targets[0],
                                types = lib.skill.reacgn_lixing_backup.types;
                            for (const t of types) await player.disableEquip(t);
                            await target.recoverTo(1);
                        },
                        ai: {
                            result: {
                                target(player, target) {
                                    if (_status.event.type != "dying") return 0;
                                    if (get.attitude(player, target) < 4) return 0;
                                    return 1;
                                },
                            },
                        },
                    };
                },
                prompt(links, player) {
                    const types = links.slice().sort((a, b) => parseInt(a.slice("equip".length)) - parseInt(b.slice("equip".length)));
                    return "废除" + types.map(i => get.translation(i) + "栏").join("、") + "，令一名角色选择执行等量项";
                },
            },
            ai: {
                order: 1,
                save: true,
                skillTagFilter(player, tag, target) {
                    return player != target;
                },
                result: {
                    player: 1,
                },
            },
            subSkill: {
                backup: {},
            },
        },
        //氷芽川四糸乃
        reacgn_bingjiekuilei: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            enable: "phaseUse",
            filter(event, player) {
                return player.getStorage("reacgn_bingjiekuilei_used").length < 2;
            },
            chooseButton: {
                dialog(event, player) {
                    const deslist = [
                        "选择一名角色并指定一种花色，直到其下个回合结束，你与其此花色的手牌均视为冰【杀】",
                        "将一张梅花手牌置入你一个空置的装备栏",
                    ];
                    const dialog = ui.create.dialog('冰结傀儡');
                    dialog.add([
                        deslist.map((item, i) => {
                            return [i, item];
                        }),
                        "textbutton",
                    ]);
                    dialog.direct = true;
                    return dialog;
                },
                filter(button) {
                    const player = get.player();
                    if (button.link == 1 && !player.hasCard(function (card) {
                        return get.suit(card) == 'club';
                    }) && Array.from({ length: 5 })
                        .map((_, i) => i + 1)
                        .every(i => !player.hasEmptySlot(i))) return false;
                    return !player.getStorage("reacgn_bingjiekuilei_used").includes(button.link)
                },
                backup(links) {
                    const next = get.copy(lib.skill.reacgn_bingjiekuilei.backups[links[0]]);
                    next.audio = "reacgn_bingjiekuilei";
                    return next;
                },
                check(button) {
                    const player = get.player();
                    switch (button.link) {
                        case 0:
                            {
                                return 1.2 + Math.random();
                            }
                            break;
                        case 1:
                            {
                                return 1.1 + Math.random();
                            }
                            break;
                    }
                    return 1;
                },
                prompt(links) {
                    return [
                        "选择一名角色并指定一种花色，直到其下个回合结束，你与其此花色的手牌均视为冰【杀】",
                        "将一张梅花手牌置入你一个空置的装备栏",
                    ][links[0]];
                },
            },
            backups: [{
                chooseButton: {
                    dialog() {
                        return ui.create.dialog("###冰结傀儡###" + '选择一名角色并指定一种花色，直到其下个回合结束，你与其此花色的手牌均视为冰【杀】');
                    },
                    chooseControl(event, player) {
                        var list = lib.suit.slice(0);
                        list.push("cancel2");
                        return list;
                    },
                    check(event, player) {
                        var map = {},
                            hs = player.getCards("h"),
                            min = Infinity,
                            min_suit = null;
                        for (var i of hs) {
                            var suit = get.suit(i, player);
                            if (!map[suit]) map[suit] = 0;
                            map[suit] += get.value(i);
                        }
                        for (var i in map) {
                            if (map[i] < min) {
                                min = map[i];
                                min_suit = i;
                            }
                        }
                        return min_suit;
                    },
                    backup(result, player) {
                        return {
                            suit: result.control,
                            filterCard: () => false,
                            selectCard: -1,
                            ai1(card) {
                                return 1;
                            },
                            filterTarget: lib.filter.notMe,
                            async content(event, trigger, player) {
                                const target = event.target;
                                if (!player.storage.reacgn_bingjiekuilei_used) {
                                    player.when(["phaseUseAfter", "phaseUseSkipped"])
                                        .then(() => {
                                            delete player.storage.reacgn_bingjiekuilei_used;
                                        })
                                }
                                player.markAuto("reacgn_bingjiekuilei_used", [0]);
                                player.addAdditionalSkill(`reacgn_bingjiekuilei_${target.playerid}`, 'reacgn_bingjiekuilei_blocker');
                                player.markAuto('reacgn_bingjiekuilei_blocker', [lib.skill.reacgn_bingjiekuilei_backup_backup.suit]);
                                target.addAdditionalSkill(`reacgn_bingjiekuilei_${target.playerid}`, 'reacgn_bingjiekuilei_blocker');
                                target.markAuto('reacgn_bingjiekuilei_blocker', [lib.skill.reacgn_bingjiekuilei_backup_backup.suit]);
                                target.addSkill('reacgn_bingjiekuilei_clear');
                            },
                            ai: {
                                result: {
                                    target(player, target) {
                                        return -1 * (target.getStorage("reacgn_bingjiekuilei_used").length + 1);
                                    },
                                },
                            },
                        };
                    },
                    prompt: () => "请选择【冰结傀儡】的目标",
                },
            },
            {
                chooseButton: {
                    dialog(event, player) {
                        return ui.create.dialog("###冰结傀儡###你可将一张梅花手牌置于你的空置装备栏内");
                    },
                    chooseControl(event, player) {
                        const choices = [];
                        for (let i = 0; i <= 5; i++) {
                            if (player.hasEmptySlot(i)) choices.push(`equip${i}`);
                        }
                        choices.push("cancel2");
                        return choices;
                    },
                    check(event, player) {
                        for (let i = 0; i <= 5; i++) {
                            if (player.hasEmptySlot(i)) return `equip${i}`;
                        }
                        return "cancel2";
                    },
                    backup(result, player) {
                        return {
                            slot: result.control,
                            filterCard(card) {
                                return get.suit(card) == 'club';
                            },
                            ai1(card) {
                                return 7 - get.value(card);
                            },
                            discard: false,
                            lose: false,
                            delay: false,
                            prepare: "throw",
                            async content(event, trigger, player) {
                                if (!player.storage.reacgn_bingjiekuilei_used) {
                                    player.when(["phaseUseAfter", "phaseUseSkipped"])
                                        .then(() => {
                                            delete player.storage.reacgn_bingjiekuilei_used;
                                        })
                                }
                                player.markAuto("reacgn_bingjiekuilei_used", [1]);
                                const card = get.autoViewAs(event.cards[0]);
                                card.subtypes = [lib.skill.reacgn_bingjiekuilei_backup_backup.slot];
                                await player.equip(card);
                            },
                            ai: {
                                result: {
                                    player(player) {
                                        return 1;
                                    },
                                },
                            },
                        }
                    },
                    prompt(result, player) {
                        return `选择一张♣手牌置入${get.translation(result.control)}栏`;
                    },
                },
            },
            ],
            /*ai: {
                order: 10,
                result: {
                    player(player) {
                        if(player.getStorage("reacgn_bingjiekuilei_used").includes(0)){
                            if(!player.countCards('h',{suit:'club'})) return 0;
                            if(Array.from({ length: 5 })
                                .map((_, i) => i + 1)
                                .every(i => !player.hasEmptySlot(i))) return 0;
                        }
                        if(player.getStorage("reacgn_bingjiekuilei_used").includes(1)){
                            if(player.getStorage("reacgn_bingjiekuilei_blocker").length > 2) return 0;
                        }
                        return 1;
                    },
                },
            },*/
            subSkill: {
                backup: {},
                backup_backup: {},
                blocker: {
                    onremove: true,
                    charlotte: true,
                    mod: {
                        cardname(card, player, name) {
                            if (player.getStorage('reacgn_bingjiekuilei_blocker').includes(get.suit(card))) return "sha";
                        },
                        cardnature(card, player) {
                            if (player.getStorage('reacgn_bingjiekuilei_blocker').includes(get.suit(card))) return "ice";
                        },
                    },
                    mark: true,
                    intro: {
                        content: `你的$花色手牌均视为冰【杀】`,
                    },
                },
                clear: {
                    trigger: {
                        player: ["phaseEnd", "dieAfter"],
                    },
                    charlotte: true,
                    forced: true,
                    popup: false,
                    forceDie: true,
                    async content(event, trigger, player) {
                        game.countPlayer(target => {
                            var skills = target.additionalSkills[`reacgn_bingjiekuilei_${player.playerid}`];
                            if (skills && skills.length) {
                                target.removeAdditionalSkill(`reacgn_bingjiekuilei_${player.playerid}`);
                            }
                        });
                    },
                },
            },
        },
        reacgn_dongkai: {
            audio: 'ext:约会大作战/audio:4',
            trigger: {
                player: 'damageBegin4',
            },
            forced: true,
            filter(event, player) {
                return event.hasNature() && player.getEquips(2).length;
            },
            async content(event, trigger, player) {
                trigger.cancel();
            },
            mod: {
                cardUsable(card, player, num) {
                    const suits = player.getCards('e')
                        .map(card => get.suit(card));
                    if (suits.includes(get.suit(card))) return Infinity;
                },
            },
        },
        reacgn_cibei: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                global: "useCardToTargeted",
            },
            filter(event, player) {
                if (!player.countCards('e')) return false;
                return event.card.name == "sha" && event.targets.length == 1 && get.distance(player, event.target) <= 1 && event.target.isIn();
            },
            check(event, player) {
                return get.attitude(player, event.target) > 0;
            },
            logTarget: "player",
            async cost(event, trigger, player) {
                event.result = await player.chooseCard("e", `###${get.prompt(event.name.slice(0, -5))}###交给${get.translation(get.translation(trigger.player))}装备区的一张牌`)
                    .set("ai", function (card) {
                        if (get.type(card) == "equip") return 1;
                        return 0;
                    })
                    .forResult();
            },
            async content(event, trigger, player) {
                await player.give(event.cards, trigger.player, "give");
                trigger.target.changeHujia(1, null, true);
            },
        },
        //五河琴里
        reacgn_zhuolanjiangui: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:4',
            mark: true,
            marktext: "☯",
            zhuanhuanji: true,
            intro: {
                content(storage, player, skill) {
                    if (!storage) return '斧：你使用牌无次数限制。';
                    return '炮：你使用牌无距离限制。';
                },
            },
            enable: "phaseUse",
            usable: 1,
            filter(event, player) {
                const num = player.getShownCards().length;
                if (player.storage.reacgn_zhuolanjiangui) return player.countCards('he') >= num;
                return true;
            },
            filterCard(card) {
                const player = get.player();
                return player.storage.reacgn_zhuolanjiangui ? true : false;
            },
            selectCard() {
                const player = get.player(),
                    num = player.getShownCards().length;
                return player.storage.reacgn_zhuolanjiangui ? num : -1;
            },
            lose: false,
            discard: false,
            delay: false,
            async content(event, trigger, player) {
                await player.changeZhuanhuanji(event.name);
                player.changeSkin({ characterName: "db_reacgn_itsukakotori" }, "db_reacgn_itsukakotori" + (player.storage[event.name] ? "_gun" : "_axe"));
                if (player.storage[event.name]) {
                    const num = player.getShownCards().length;
                    if (num > 0) player.draw(num);
                }
                else {
                    const cards = event.cards;
                    if (cards.length) {
                        await player.loseToDiscardpile(cards, ui.cardPile, false, "blank").set('log', false);
                        const shownCards = cards.filter(i => get.position(i) == "e"),
                            handcardsLength = cards.length - shownCards.length;
                        if (shownCards.length) {
                            player.$throw(shownCards, null);
                            game.log(player, "将", shownCards, "置于了牌堆底");
                        }
                        if (handcardsLength > 0) {
                            player.$throw(handcardsLength, null);
                            game.log(player, "将", get.cnNumber(handcardsLength), "张牌置于了牌堆底");
                        }
                    }
                    var viewAs = new lib.element.VCard({ name: 'sha', nature: 'fire', isCard: true });
                    player.chooseUseTarget(viewAs, 'nodistance').set('oncard', () => get.event().baseDamage++);
                }
            },
            ai: {
                order: 1,
                result: {
                    player(player) {
                        return 1;
                    },
                },
            },
            mod: {
                cardUsable(card, player, num) {
                    if (!player.storage.reacgn_zhuolanjiangui) return Infinity;
                },
                targetInRange(card, player, target) {
                    if (player.storage.reacgn_zhuolanjiangui) return true;
                },
            },
        },
        reacgn_yuyi: {
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                global: "phaseEnd",
            },
            async cost(event, trigger, player) {
                event.result = await player.chooseCard(get.prompt2(event.name.slice(0, -5)))
                    .set('ai', card => {
                        const player = get.player(),
                            visible = get.is.shownCard(card);
                        if (visible) {
                            if (player.isHealthy()) return 0;
                            return 6 - get.value(card);
                        }
                        return 8 - get.value(card);
                    })
                    .forResult();
            },
            async content(event, trigger, player) {
                if (!get.is.shownCard(event.cards[0])) {
                    player.addShownCards(event.cards, 'visible_reacgn');
                } else {
                    await player.loseToDiscardpile(event.cards, ui.cardPile, false, "blank").set('log', false);
                    game.log(player, "将一张牌置于了牌堆底");
                    await player.recover();
                }
            },
        },
        reacgn_yanli: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                global: "roundStart",
            },
            forced: true,
            getCards() {
                const cards = [];
                for (var i = 0; i < ui.discardPile.childNodes.length; i++) {
                    var card = ui.discardPile.childNodes[i];
                    if (get.tag(card, 'fireDamage')) cards.add(card);
                }
                return cards;
            },
            filter(event, player) {
                return get.info('reacgn_yanli').getCards().length;
            },
            async content(event, trigger, player) {
                const cards = get.info('reacgn_yanli').getCards();
                if (cards.length) {
                    await player.gain(cards, 'gain2');
                    await player.addShownCards(cards, 'visible_reacgn');
                }
            },
            mod: {
                ignoredHandcard(card, player) {
                    if (get.is.shownCard(card)) return true;
                },
                cardDiscardable(card, player, name) {
                    if (name == "phaseDiscard" && get.is.shownCard(card)) return false;
                },
            },
        },
        //星宮六喰
        reacgn_fengjiezhu: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            enable: "phaseUse",
            usable: 1,
            filter(event, player) {
                return player.getStorage('reacgn_fengjiezhu').length;
            },
            init(player, skill) {
                player.storage[skill] = get.info(skill).getList(player);
            },
            getList(player) {
                if (!player.storage.reacgn_fengjiezhu) return [0, 1, 2, 3];
                return player.storage.reacgn_fengjiezhu.slice(0);
            },
            getInfo(player) {
                const num = player.maxHp,
                    info = [
                        `封：令一名角色的一个技能失效，直到此后有${num}张牌进入弃牌堆`,
                        `解：弃置一名角色区域内的${num}张牌`,
                        `闭：令一名角色不能使用或打出牌，直到此后有${num}张牌进入弃牌堆`,
                        `开：令一名角色摸${num}张牌`,
                    ];
                return info;
            },
            chooseButton: {
                dialog(event, player) {
                    const dialog = ui.create.dialog('封解主');
                    dialog.add([
                        get.info("reacgn_fengjiezhu").getInfo(player).map((item, i) => {
                            return [i, item];
                        }),
                        "textbutton",
                    ]);
                    dialog.direct = true;
                    return dialog;
                },
                filter(button) {
                    const player = get.player();
                    if (!player.getStorage("reacgn_fengjiezhu").includes(button.link)) return false;
                    switch (button.link) {
                        case 0:
                            {
                                return game.hasPlayer(target => {
                                    return target;
                                });
                            }
                        case 1:
                            {
                                return game.hasPlayer(target => {
                                    return target.countDiscardableCards(player, 'hej');
                                });
                            }
                        default:
                            return true;
                    }
                },
                backup(links) {
                    const next = get.copy(lib.skill.reacgn_fengjiezhu.backups[links[0]]);
                    next.audio = "reacgn_fengjiezhu";
                    return next;
                },
                check(button) {
                    const player = get.player();
                    switch (button.link) {
                        case 0:
                            {
                                return 1;
                            }
                        case 1:
                            {
                                return 1.1;
                            }
                        case 2:
                            {
                                return 1.2;
                            }
                        case 3:
                            {
                                return 1.3;
                            }
                    }
                },
                prompt(links) {
                    const num = get.player().maxHp;
                    const deslist = [
                        `封：令一名角色的一个技能失效，直到此后有${num}张牌因弃置而进入弃牌堆`,
                        `解：弃置一名角色区域内的${num}张牌`,
                        `闭：令一名角色不能使用或打出牌，直到此后有${num}张牌因弃置而进入弃牌堆`,
                        `开：令一名角色摸${num}张牌`,
                    ];
                    return deslist[links[0]];
                },
            },
            backups: [{
                filterTarget(card, player, target) {
                    return true;
                },
                async content(event, trigger, player) {
                    const target = event.targets[0];
                    const skills = target.getSkills(null, false, false).filter(function (i) {
                        var info = get.info(i);
                        return info && !info.charlotte && lib.translate[i + '_info'];
                    });
                    if (skills.length) {
                        const list = skills.map(skill => [skill, '【' + get.translation(skill) + '】：' + lib.translate[skill + '_info']]);
                        const { result: { bool, links } } = await player.chooseButton([`###封解主·封###令${get.translation(target)}的一个技能失效`, [list, 'textbutton']], true)
                            .set('ai', button => {
                                return 1 + Math.random();
                            });
                        if (bool) {
                            target.disableSkill('reacgn_fengjiezhu_disable', links);
                            target.addSkill('reacgn_fengjiezhu_feng');
                            target.setStorage('reacgn_fengjiezhu_feng', player.maxHp);
                        }
                    }
                },
                ai: {
                    order: 10,
                    result: {
                        target(player, target) {
                            return -1;
                        },
                    },
                },
            },
            {
                filterTarget(card, player, target) {
                    return target.countDiscardableCards(player, 'hej');
                },
                async content(event, trigger, player) {
                    player.discardPlayerCard(event.targets[0], 'hej', player.maxHp)
                },
                ai: {
                    order: 10,
                    result: {
                        target(player, target) {
                            return -1;
                        },
                    },
                },
            },
            {
                filterTarget(card, player, target) {
                    return true;
                },
                async content(event, trigger, player) {
                    const target = event.targets[0];
                    target.addSkill('reacgn_fengjiezhu_bi');
                    target.setStorage('reacgn_fengjiezhu_bi', player.maxHp);
                },
                ai: {
                    order: 10,
                    result: {
                        target(player, target) {
                            return -1;
                        },
                    },
                },
            },
            {
                filterTarget(card, player, target) {
                    return true;
                },
                async content(event, trigger, player) {
                    event.targets[0].draw(player.maxHp);
                },
                ai: {
                    order: 10,
                    result: {
                        target(player, target) {
                            return player.maxHp;
                        },
                    },
                },
            },
            ],
            ai: {
                order: 10,
                result: {
                    player(player) {
                        return 1;
                    },
                },
            },
            subSkill: {
                backup: {},
                feng: {
                    trigger: {
                        global: ["loseAfter", "cardsDiscardAfter", "loseAsyncAfter", "equipAfter"],
                    },
                    forced: true,
                    firstDo: true,
                    charlotte: true,
                    onremove: true,
                    filter(event, player) {
                        return event.getd() && event.getd().length;
                    },
                    async content(event, trigger, player) {
                        if (typeof player.storage.reacgn_fengjiezhu_feng == "number") {
                            player.storage.reacgn_fengjiezhu_feng -= trigger.getd().length;
                            if (player.storage.reacgn_fengjiezhu_feng < 0) player.storage.reacgn_fengjiezhu_feng = 0;
                        }
                        if (!player.storage.reacgn_fengjiezhu_feng) {
                            player.removeSkill(event.name);
                            player.enableSkill('reacgn_fengjiezhu_disable');
                        }
                    },
                    mark: true,
                    marktext: '封',
                    intro: {
                        content: (storage) => `你的一个技能失效，直到此后有${storage}张牌进入弃牌堆`,
                    },
                },
                jie: {},
                bi: {
                    trigger: {
                        global: ["loseAfter", "cardsDiscardAfter", "loseAsyncAfter", "equipAfter"],
                    },
                    forced: true,
                    firstDo: true,
                    charlotte: true,
                    onremove: true,
                    filter(event, player) {
                        return event.getd() && event.getd().length;
                    },
                    async content(event, trigger, player) {
                        if (typeof player.storage.reacgn_fengjiezhu_bi == "number") {
                            player.storage.reacgn_fengjiezhu_bi -= trigger.getd().length;
                            if (player.storage.reacgn_fengjiezhu_bi < 0) player.storage.reacgn_fengjiezhu_bi = 0;
                        }
                        if (!player.storage.reacgn_fengjiezhu_bi) {
                            player.removeSkill(event.name);
                        }
                    },
                    mod: {
                        cardEnabled2: () => false,
                    },
                    mark: true,
                    marktext: '闭',
                    intro: {
                        content: (storage) => `你不能使用或打出牌，直到此后有${storage}张牌进入弃牌堆`,
                    },
                },
                kai: {},
            },
        },
        reacgn_xinsheng: {
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                player: "phaseZhunbeiBegin",
            },
            forced: true,
            juexingji: true,
            skillAnimation: true,
            animationColor: "qun",
            filter(event, player) {
                if (!player.hasSkill('reacgn_fengjiezhu')) return false;
                return !player.getStorage('reacgn_fengjiezhu').length;
            },
            async content(event, trigger, player) {
                player.awakenSkill(event.name);
                const { result: { bool, links } } = await player.chooseButton([`${get.prompt2(event.name)}`, [
                    [
                        [0, "　　　封：令角色技能失效　　　"],
                        [1, "　　　解：弃置区域内的牌　　　"],
                    ],
                    "tdnodes",
                ],
                [
                    [
                        [2, "　　　闭：不能使用打出牌　　　"],
                        [3, "　　　开：令一名角色摸牌　　　"],
                    ],
                    "tdnodes",
                ]
                ])
                    .set('filterButton', button => {
                        const player = get.player();
                        return !player.getStorage('reacgn_fengjiezhu').includes(button.link)
                    })
                    .set('selectButton', button => {
                        const player = get.player(),
                            num = 4 - player.getStorage('reacgn_fengjiezhu').length;
                        return [1, num];
                    })
                    .set('ai', button => {
                        const player = get.player();
                        return 2 + Math.random();
                    });
                if (bool) {
                    player.markAuto('reacgn_fengjiezhu', links);
                    await player.loseMaxHp(links.length);
                    player.draw(links.length);
                }
            },
            ai: {
                combo: 'reacgn_fengjiezhu',
            },
        },
        reacgn_qimei: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                player: "damageBegin4",
            },
            popup: false,
            filter(event, player) {
                if (!player.hasSkill('reacgn_fengjiezhu')) return false;
                return player.getStorage('reacgn_fengjiezhu').length;
            },
            async cost(event, trigger, player) {
                const { result: { bool, links } } = await player.chooseButton([`${get.prompt2(event.name.slice(0, -5))}`, [
                    [
                        [0, "　　　封：令角色技能失效　　　"],
                        [1, "　　　解：弃置区域内的牌　　　"],
                    ],
                    "tdnodes",
                ],
                [
                    [
                        [2, "　　　闭：不能使用打出牌　　　"],
                        [3, "　　　开：令一名角色摸牌　　　"],
                    ],
                    "tdnodes",
                ]
                ])
                    .set('filterButton', button => {
                        const player = get.player();
                        return player.getStorage('reacgn_fengjiezhu').includes(button.link)
                    })
                    .set('selectButton', button => {
                        const player = get.player(),
                            num = 4 - player.getStorage('reacgn_fengjiezhu').length;
                        return [1, num];
                    })
                    .set('ai', button => {
                        return 1 + Math.random();
                    });
                if (bool) event.result = { bool, cost_data: { links } };
            },
            async content(event, trigger, player) {
                const links = event.cost_data.links;
                player.logSkill(event.name);
                await game.asyncDelay();
                player.popup(['封', '解', '闭', '开'][links[0]]);
                trigger.cancel();
                game.log(player, '防止了此次伤害');
                player.unmarkAuto('reacgn_fengjiezhu', links);
                await player.gainMaxHp();
            },
            ai: {
                combo: 'reacgn_fengjiezhu',
            },
        },
        //镜野七罪
        reacgn_yanzaomonv: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                global: "phaseBegin",
            },
            popup: false,
            async cost(event, trigger, player) {
                event.result = await player.chooseTarget(get.prompt2(event.name.slice(0, -5)))
                    .set('filterTarget', (card, player, target) => {
                        return target != player && !player.hasAllHistory('useSkill', evt => evt.skill == 'reacgn_yanzaomonv' && evt.targets.includes(target))
                    })
                    .set('ai', target => {
                        return 1 + Math.random();
                    })
                    .forResult();
            },
            async content(event, trigger, player) {
                const target = event.targets[0];
                player.logSkill(event.name, target);
                player.tempBanSkill(event.name, 'roundStart', false);
                const skills = target.getSkills(null, false, false).filter(function (i) {
                    var info = get.info(i);
                    return info && !info.charlotte && lib.translate[i + '_info'];
                });
                if (skills.length) {
                    const list = skills.map(skill => [skill, '【' + get.translation(skill) + '】：' + lib.translate[skill + '_info']]);
                    const { result: { bool, links } } = await player.chooseButton([`###赝造魔女###获得${get.translation(target)}的一个技能直到当前回合结束`, [list, 'textbutton']], true)
                        .set('ai', button => {
                            const player = get.player();
                            return 1 + Math.random();
                        });
                    if (bool) {
                        player.addTempSkills(links);
                    }
                }
            },
        },
        reacgn_qianbianwanhuajing: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:4',
            enable: "phaseUse",
            usable: 1,
            mark: true,
            marktext: "☯",
            zhuanhuanji: true,
            intro: {
                content(storage, player, skill) {
                    if (!storage) return '阳：出牌阶段限一次，你可以选择一名角色的一张手牌，令其将此牌当做你指定牌名的装备牌使用。';
                    return '阴：选择一名角色装备区内的一张牌，令其将此牌当做你指定牌名的一张基本牌或普通锦囊牌使用。';
                },
            },
            filterTarget(card, player, target) {
                const storage = player.storage.reacgn_qianbianwanhuajing,
                    position = (!storage ? 'h' : 'e');
                return target.countCards(position, card => {
                    const mod2 = game.checkMod(card, target, "unchanged", "cardEnabled2", target);
                    return mod2 !== false;
                });
            },
            prompt() {
                const player = get.player(),
                    storage = player.storage.reacgn_qianbianwanhuajing;
                if (!storage) return '阳：出牌阶段限一次，你可以选择一名角色的一张手牌，令其将此牌当做你指定牌名的装备牌使用。';
                return '阴：选择一名角色装备区内的一张牌，令其将此牌当做你指定牌名的一张基本牌或普通锦囊牌使用。';
            },
            async content(event, trigger, player) {
                await player.changeZhuanhuanji(event.name);
                player.changeSkin({ characterName: "db_reacgn_kagaminonatsumi" }, "db_reacgn_kagaminonatsumi" + (player.storage[event.name] ? "_shadow" : ""));
                const target = event.target,
                    storage = player.storage[event.name],
                    position = storage ? 'h' : 'e';
                const { result: { bool, links } } = await player.choosePlayerCard(target, position, true)
                    .set('sourcex', target)
                    .set('filterButton', button => {
                        const target = get.event('sourcex');
                        const mod2 = game.checkMod(button.link, target, "unchanged", "cardEnabled2", target);
                        return mod2 !== false;
                    })
                    .set('ai', button => {
                        return 1 + Math.random();
                    });
                if (bool) {
                    const list = get.inpileVCardList(info => {
                        const name = info[2], type = get.type(name), infox = get.info({ name: name });
                        if (!storage) return ['basic', 'trick'].includes(type);
                        return type == 'equip';
                    }).filter(card => target.hasUseTarget({ name: card[2], nature: card[3] }));
                    if (!list.length) return;
                    const description = storage ? `令${get.translation(target)}将此牌当做你指定牌名的装备牌使用` : `令${get.translation(target)}将此牌当做你指定牌名的一张基本牌或普通锦囊牌使用`;
                    const { result } = await player.chooseButton([description, [list, "vcard"]])
                        .set('sourcex', target)
                        .set('filterButton', button => {
                            const target = get.event('sourcex');
                            return target.hasUseTarget({ name: button.link[2], nature: button.link[3] });
                        })
                        .set('ai', button => {
                            return 1 + Math.random();
                        });
                    if (result.bool) {
                        const card = get.autoViewAs({ name: result.links[0][2], nature: result.links[0][3] }, links);
                        if (target.hasUseTarget(card)) await target.chooseUseTarget(card, links, true);
                    }
                }
            },
            ai: {
                order: 1,
                result: {
                    target(player, target) {
                        return 1;
                    },
                },
            },
        },
        reacgn_shengli: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                global: "phaseZhunbeiBegin"
            },
            filter(event, player) {
                const cards1 = event.player.getVCards('e').map(card => card.name),
                    cards2 = player.getVCards('e').map(card => card.name);
                return event.player != player && cards1.some(info => cards2.includes(info));
            },
            logTarget: 'player',
            async cost(event, trigger, player) {
                event.result = await player.chooseTarget(get.prompt2(event.name.slice(0, -5)))
                    .set('filterTarget', (card, player, target) => {
                        return get.info('reacgn_qianbianwanhuajing').filterTarget(null, player, target)
                    })
                    .set('ai', target => {
                        const player = get.player();
                        return get.info('reacgn_qianbianwanhuajing').ai.result.target(player, target);
                    })
                    .forResult();
            },
            async content(event, trigger, player) {
                player.useSkill('reacgn_qianbianwanhuajing', event.targets);
            },
        },
        //八舞耶倶矢
        //八舞夕弦
        reacgn_jufengqishi: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:1',
            mod: {
                aiOrder(player, card, num) {
                    if (typeof card == "object" && player.isPhaseUsing()) {
                        var evt = lib.skill.reacgn_jufengqishi.getLastUsed(player);
                        if (evt && evt.card && (get.type2(evt.card) && get.type2(evt.card) == get.type2(card))) {
                            return num + 10;
                        }
                    }
                },
            },
            trigger: {
                player: "useCard",
            },
            forced: true,
            getLastUsed(player, event) {
                var history = player.getAllHistory("useCard");
                var index;
                if (event) index = history.indexOf(event) - 1;
                else index = history.length - 1;
                if (index >= 0) return history[index];
                return false;
            },
            filter(event, player) {
                var evt = lib.skill.reacgn_jufengqishi.getLastUsed(player, event);
                if (!evt || !evt.card) return false;
                return true;
            },
            async content(event, trigger, player) {
                if ((() => {
                    var evt = lib.skill.reacgn_jufengqishi.getLastUsed(player, trigger);
                    if (!evt || !evt.card) return false;
                    return (get.type2(evt.card, false) == get.type2(trigger.card));
                })()) {
                    await player.draw();
                } else {
                    if (player.hasCard(function (card) {
                        return lib.filter.cardDiscardable(card, player, 'reacgn_jufengqishi');
                    }, 'he')) {
                        await player.chooseToDiscard('he', true);
                    }
                    player.tempBanSkill(event.name);
                }
            },
            init(player, skill) {
                player.addSkill("reacgn_jufengqishi_mark");
                var history = player.getAllHistory("useCard");
                if (history.length) {
                    var trigger = history[history.length - 1];
                    player.storage.reacgn_jufengqishi_mark = trigger.card;
                    player.markSkill("reacgn_jufengqishi_mark");
                    game.broadcastAll(
                        function (player, type) {
                            if (player.marks.reacgn_jufengqishi_mark) player.marks.reacgn_jufengqishi_mark.firstChild.innerHTML = get.translation(type);
                        },
                        player,
                        get.type2(trigger.card, player)
                    );
                    player.addTip(skill, get.translation(skill) + " " + get.translation(get.type2(trigger.card, player)));
                }
            },
            onremove(player, skill) {
                player.removeSkill("reacgn_jufengqishi_mark");
                delete player.storage.reacgn_jufengqishi_mark;
                player.removeTip(skill);
            },
            subSkill: {
                mark: {
                    charlotte: true,
                    trigger: {
                        player: "useCard1",
                    },
                    forced: true,
                    popup: false,
                    firstDo: true,
                    onremove: true,
                    async content(event, trigger, player) {
                        player.storage.reacgn_jufengqishi_mark = trigger.card;
                        player.markSkill("reacgn_jufengqishi_mark");
                        game.broadcastAll(
                            function (player, type) {
                                if (player.marks.reacgn_jufengqishi_mark) player.marks.reacgn_jufengqishi_mark.firstChild.innerHTML = get.translation(type);
                            },
                            player,
                            get.type2(trigger.card, player)
                        );
                        lib.skill.reacgn_jufengqishi.init(player, "reacgn_jufengqishi");
                    },
                    intro: {
                        markcount(card, player) {
                            return get.translation(get.type2(card, player));
                        },
                        content(card, player) {
                            var type = get.type2(card, player);
                            var str = "上一张牌的类型：" + get.translation(type);
                            return str;
                        },
                    },
                },
            },
        },
        reacgn_shufuzhe: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:1',
            enable: "phaseUse",
            usable: 1,
            viewAs: {
                name: "tiesuo",
            },
            viewAsFilter(player) {
                if (!player.countCards('h')) return false;
            },
            filterCard: true,
            selectCard: -1,
            async precontent(event, trigger, player) {
                player.when('useCardAfter')
                    .filter(event => event.skill == 'reacgn_shufuzhe')
                    .then(() => {
                        const next = game.createEvent('reacgn_shufuzhe_link');
                        next.player = player;
                        next.setContent((async (event, trigger, player) => {
                            const targets = game.filterPlayer(target => {
                                return target.isLinked() && target.countDiscardableCards(player, 'he');
                            });
                            if (targets.length) {
                                for (const target of targets) {
                                    if (target.countDiscardableCards(player, 'he')) await player.discardPlayerCard(target, 'he');
                                }
                            }
                            const { result: { bool } } = await player.chooseBool(`你可以将武将牌翻面`)
                                .set('ai', () => {
                                    const player = get.player();
                                    return true;
                                });
                            if (bool) {
                                player.turnOver();
                            }
                        }));
                    });
            },
        },
        reacgn_chuancizhe: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:1',
            enable: "phaseUse",
            usable: 1,
            locked: false,
            filter(event, player) {
                var hs = player.getCards("h");
                if (!hs.length) return false;
                for (var i = 0; i < hs.length; i++) {
                    var mod2 = game.checkMod(hs[i], player, "unchanged", "cardEnabled2", player);
                    if (mod2 === false) return false;
                }
                return event.filterCard(get.autoViewAs({ name: "sha" }, "unsure"), player, event) || lib.inpile_nature.some(nature => event.filterCard(get.autoViewAs({ name: "sha", nature }, "unsure"), player, event));
            },
            chooseButton: {
                dialog(event, player) {
                    var list = [];
                    if (event.filterCard({ name: "sha" }, player, event)) list.push(["基本", "", "sha"]);
                    for (var j of lib.inpile_nature) {
                        if (event.filterCard({ name: "sha", nature: j }, player, event)) list.push(["基本", "", "sha", j]);
                    }
                    var dialog = ui.create.dialog("穿刺者", [list, "vcard"], "hidden");
                    dialog.direct = true;
                    return dialog;
                },
                check(button) {
                    var player = _status.event.player;
                    var card = { name: button.link[2], nature: button.link[3] };
                    if (
                        _status.event.getParent().type == "phase" &&
                        game.hasPlayer(function (current) {
                            return player.canUse(card, current) && get.effect(current, card, player, player) > 0;
                        })
                    ) {
                        switch (button.link[2]) {
                            case "sha":
                                if (button.link[3] == "fire") return 2.95;
                                else if (button.link[3] == "thunder" || button.link[3] == "ice") return 2.92;
                                else return 2.9;
                        }
                    }
                    return 1 + Math.random();
                },
                backup(links, player) {
                    return {
                        filterCard: true,
                        selectCard: -1,
                        selectTarget() {
                            return [1, ui.selected.cards.length];
                        },
                        ai1(card) {
                            return 1;
                        },
                        viewAs: {
                            name: links[0][2],
                            nature: links[0][3],
                        },
                        popname: true,
                        log: false,
                        async precontent(event, trigger, player) {
                            player.logSkill("reacgn_chuancizhe");
                            player.when('useCardAfter')
                                .filter(event => event.skill == 'reacgn_chuancizhe_backup')
                                .then(() => {
                                    const next = game.createEvent('reacgn_chuancizhe_sha');
                                    next.player = player;
                                    next.setContent((async (event, trigger, player) => {
                                        const { result: { bool } } = await player.chooseBool(`你可以将武将牌翻面`)
                                            .set('ai', () => {
                                                const player = get.player();
                                                return true;
                                            });
                                        if (bool) {
                                            player.turnOver();
                                        }
                                    }));
                                });
                        },
                    };
                },
                prompt(links, player) {
                    return "将所有手牌当作" + get.translation(links[0][3] || "") + "【" + get.translation(links[0][2]) + "】" + (_status.event.name == "chooseToUse" ? "使用" : "打出");
                },
            },
            ai: {
                order: 1,
                result: {
                    player(player) {
                        var num = 0;
                        var cards = player.getCards("h");
                        if (cards.length >= 3 && player.hp >= 3) return 0;
                        for (var i = 0; i < cards.length; i++) {
                            num += Math.max(0, get.value(cards[i], player, "raw"));
                        }
                        return 16 - num;
                    },
                },
            },
            subSkill: {
                backup: {},
            },
        },
        reacgn_rongyao: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:1',
            trigger: {
                player: "changeCharacterEnd",
            },
            frequent: true,
            async content(event, trigger, player) {
                player.draw(2);
            },
        },
        //诱宵美九
        reacgn_pojungeji: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                player: "loseAfter",
                global: "cardsDiscardAfter",
            },
            isUse(event, player) {
                if (event.name !== "cardsDiscard") return false;
                const evtx = event.getParent();
                if (evtx.name !== "orderingDiscard") return false;
                const evt2 = evtx.relatedEvent || evtx.getParent();
                return evt2.name == "useCard" && evt2.player == player;
            },
            filter(event, player) {
                if (!get.info("reacgn_pojungeji").isUse(event, player)) return false;
                return event.getd(player, "cards").length;
            },
            async content(event, trigger, player) {
                const cards2 = trigger.getd(player, "cards")
                    .filter(card => typeof get.number(card, false) == "number"),
                    cards = player.getExpansions("reacgn_pojungeji");
                if (cards2.length) {
                    player.markSkill("reacgn_pojungeji");
                    await player.addToExpansion(cards2, player, 'giveAuto').set("gaintag", ["reacgn_pojungeji"]);
                }
                if (cards2.length > 1 || !cards.length || cards.length < 1) return;
                const num = get.number(cards2[0], false),
                    index = cards.map(card => get.number(card, false));
                const min = Math.min(...index),
                    max = Math.max(...index),
                    isArrayContinue = function (array) {
                        if (!array) {
                            return false;
                        }
                        if (array.length == 0) {
                            return false;
                        }
                        var len = array.length;
                        var n0 = array[0];
                        var sortDirection = 1;
                        if (array[0] > array[len - 1]) {
                            sortDirection = -1;
                        }
                        if ((n0 * 1 + (len - 1) * sortDirection) !== array[len - 1]) {
                            return false;
                        }
                        var isContinuation = true;
                        for (var i = 0; i < len; i++) {
                            if (array[i] !== (i + n0 * sortDirection)) {
                                isContinuation = false;
                                break;
                            }
                        }
                        return isContinuation;
                    };
                if ((() => {
                    if (!isArrayContinue(index.sort((a, b) => a - b).slice(0).toUniqued())) return false;
                    return (num + 1 == min) || (num - 1 == max);
                })()) {
                    player.draw();
                }
            },
            marktext: "音",
            intro: {
                content: "expansion",
                markcount: "expansion",
            },
            onremove(player, skill) {
                var cards = player.getExpansions(skill);
                if (cards.length) player.loseToDiscardpile(cards);
            },
        },
        reacgn_kuangzou: {
            audio: 'ext:约会大作战/audio:3',
            trigger: {
                player: "phaseJieshuBegin",
            },
            filter(event, player) {
                return player.getExpansions("reacgn_pojungeji").length >= 3;
            },
            async cost(event, trigger, player) {
                const cards = player.getExpansions("reacgn_pojungeji");
                const { result: { bool, links } } = await player.chooseButton(3, [`${get.prompt2(event.name.slice(0, -5))}`, cards])
                    .set("ai", button => {
                        return 1;
                    });
                if (bool) event.result = { bool, cost_data: { links } };
            },
            async content(event, trigger, player) {
                const cards = event.cost_data.links,
                    types = cards.map(card => get.type2(card, false)),
                    colors = cards.map(card => get.color(card, false)),
                    numbers = cards.map(card => get.number(card, false));
                await player.loseToDiscardpile(cards);
                let counttrigger = 0;
                if (types.toUniqued().length == 1) {
                    const { result: { bool, targets } } = await player.chooseTarget(`进行曲：你可以令至多名角色依次各摸一张牌，然后这些角色可以依次使用一张牌。`)
                        .set('selectTarget', [1, 3])
                        .set('ai', target => {
                            return get.attitude(player, target);
                        });
                    if (bool) {
                        counttrigger++;
                        player.line(targets);
                        await game.asyncDraw(targets);
                        for (const target of targets) {
                            await target.chooseToUse(function (card) {
                                if (!lib.filter.cardEnabled(card, _status.event.player, _status.event)) {
                                    return false;
                                }
                                return true;
                            });
                        }
                    }
                }
                if (colors.toUniqued().length == 1) {
                    if (_status.connectMode) game.broadcastAll(function () { _status.noclearcountdown = true });
                    const lose_list = [];
                    let num = 3;
                    while (num > 0) {
                        const result = await player.chooseTarget(
                            `圆舞曲：你可以弃置至多三名角色的共计至多三张牌`,
                            (card, player, target) => {
                                return target.hasCard(card => {
                                    const discarded = _status.event.lose_list.find(item => item[0] == target);
                                    if (discarded && discarded[1].includes(card)) return false;
                                    return lib.filter.canBeDiscarded(card, player, target, 'hoklindongyizhi');
                                }, 'he')
                            }
                        ).set('ai', target => {
                            const player = _status.event.player,
                                discarded = _status.event.lose_list.find(item => item[0] == target);
                            if (discarded) {
                                if (target == player) return 0;
                                const num = discarded[1].length;
                                if (num > 1 && player.getHp() + player.hujia > 2) return 0;
                            }
                            if (target == player) {
                                if (ui.cardPile.childNodes.length > 80 && player.hasCard(card => get.value(card) < 8)) return 20;
                                return 0;
                            }
                            return get.effect(target, { name: 'guohe_copy2' }, player, player);
                        }).set('lose_list', lose_list).forResult();
                        if (result.bool) {
                            const target = result.targets[0];
                            const cards = await player.choosePlayerCard(target, true, 'he', [1, num], `选择弃置${get.translation(target)}区域内的牌`)
                                .set('filterButton', (button) => {
                                    const card = button.link,
                                        target = _status.event.target,
                                        player = get.player();
                                    const discarded = _status.event.lose_list.find(item => item[0] == target);
                                    if (discarded && discarded[1].includes(card)) return false;
                                    return lib.filter.canBeDiscarded(card, player, target, 'hoklindongyizhi');
                                })
                                .set('lose_list', lose_list)
                                .set('ai', button => {
                                    if (ui.selected.buttons.length > 0) return false;
                                    var val = get.buttonValue(button);
                                    if (get.attitude(_status.event.player, _status.event.target) > 0) return -val;
                                    return val;
                                })
                                .forResultCards();
                            num -= cards.length;
                            const index = lose_list.find(item => item[0] == target);
                            if (!index) {
                                lose_list.push([target, cards]);
                            } else {
                                index[1].addArray(cards);
                            }
                        } else {
                            break;
                        }
                    }
                    if (_status.connectMode) {
                        game.broadcastAll(function () {
                            delete _status.noclearcountdown;
                            game.stopCountChoose()
                        });
                    }
                    if (lose_list.length > 0) {
                        counttrigger++;
                        lib.tempSortSeat = player;
                        lose_list.sort((a, b) => {
                            return lib.sort.seat(a[0], b[0]);
                        });
                        delete lib.tempSortSeat;
                        if (lose_list[0].length == 1) {
                            await lose_list[0][0].discard(lose_list[0][1]);
                        } else {
                            await game.loseAsync({
                                lose_list: lose_list,
                                discarder: player,
                            }).setContent('discardMultiple');
                        }
                    }
                }
                if (numbers.toUniqued().length == 1) {
                    const { result: { bool, targets } } = await player.chooseTarget(`镇魂曲：你可以令至多三名角色各回复1点体力。`)
                        .set('filterTarget', (card, player, target) => {
                            return target.isDamaged();
                        })
                        .set('selectTarget', [1, 3])
                        .set('ai', target => {
                            return get.attitude(player, target);
                        });
                    if (bool) {
                        counttrigger++;
                        player.line(targets);
                        for (const target of targets) {
                            await target.recover();
                        }
                    }
                }
                if (counttrigger == 3) {
                    event._reacgn_jichu = true;
                }
            },
        },
        reacgn_jichu: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:1',
            trigger: {
                player: "reacgn_kuangzouAfter",
            },
            forced: true,
            filter(event, player) {
                if (game.countPlayer() < 3) return false;
                return event._reacgn_jichu;
            },
            async content(event, trigger, player) {
                const { result: { bool, targets } } = await player.chooseTarget(`${get.prompt2(event.name)}`, 2, true)
                    .set('complexTarget', true)
                    .set('filterTarget', (card, player, target) => {
                        if (target == player) return false;
                        if (!ui.selected.targets.length) return target.countCards('h');
                        return true;
                    })
                    .set('ai', target => {
                        if (ui.selected.targets.length) return -10;
                        return target.countCards('h');
                    });
                if (bool) {
                    const cards = targets[0].getCards('h');
                    await targets[0].showCards(cards);
                    for (const card of cards) {
                        if (targets[0].canUse(card, targets[1], false, false)) {
                            await targets[0].useCard(card, targets[1], false);
                        }
                    }
                }
            },
        },
        //夜刀神十香
        reacgn_aosha: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                player: "useCardAfter",
            },
            frequent: true,
            filter(event, player) {
                return event.card.name == 'sha' || get.type(event.card) == 'equip';
            },
            async content(event, trigger, player) {
                const cards = game.cardsGotoOrdering(get.cards()).cards;
                await player.showCards(cards, get.translation(player) + "发动了〖鏖杀公〗");
                if (get.name(cards[0], false) == 'sha' || get.type(cards[0]) == 'equip') {
                    await player.chooseUseTarget(cards[0], false);
                }
            },
        },
        reacgn_zuizhongzhijian: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            enable: "phaseUse",
            limited: true,
            skillAnimation: true,
            animationColor: "key",
            async content(event, trigger, player) {
                player.awakenSkill('reacgn_zuizhongzhijian');
                await player.removeSkills('reacgn_wangzuo');
                player.addTempSkill('reacgn_zuizhongzhijian_effect');
            },
            ai: {
                order: 3,
                result: {
                    player(player, target) {
                        if (player.countCards('h', { name: 'sha' }) > 1) return 2 * player.countCards('h', { name: 'sha' });
                        return !player.hasSkill('reacgn_wangzuo');
                    },
                },
            },
            subSkill: {
                effect: {
                    trigger: {
                        player: "phaseJieshuBegin",
                    },
                    direct: true,
                    charlotte: true,
                    async content(event, trigger, player) {
                        var next = player.chooseToUse();
                        next.set("openskilldialog", `###${get.prompt("reacgn_zuizhongzhijian")}###你可以将你装备区内的所有装备牌当做一张无距离限制且伤害为X的【杀】使用（X为转化的牌数）。`);
                        next.set("norestore", true);
                        next.set("_backupevent", "reacgn_zuizhongzhijian_backup");
                        next.set("addCount", false);
                        next.set("logSkill", "reacgn_zuizhongzhijian_backup");
                        next.set("custom", {
                            add: {},
                            replace: { window: function () { } },
                        });
                        next.backup("reacgn_zuizhongzhijian_backup");
                    },
                    mod: {
                        cardUsable(card, player, num) {
                            if (card.name == 'sha') return Infinity;
                        },
                        targetInRange(card, player, target) {
                            if (card.storage && card.storage.reacgn_zuizhongzhijian) return true;
                        }
                    },
                },
                backup: {
                    filterCard(card) {
                        return get.itemtype(card) == "card";
                    },
                    viewAs: {
                        name: "sha",
                        storage: {
                            reacgn_zuizhongzhijian: true,
                        },
                    },
                    selectCard: -1,
                    position: "e",
                    "ai1"(card) {
                        var player = get.player();
                        var maxVal = 6.5;
                        return maxVal - get.value(card);
                    },
                    log: false,
                    async precontent(event, trigger, player) {
                        const num = event.result.cards.slice(0).length;
                        event.getParent().set('oncard', function () {
                            _status.event.baseDamage = num;
                        });;
                    },
                },
            },
        },
        reacgn_wangzuo: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                global: "phaseZhunbeiBegin",
            },
            direct: true,
            filter(event, player) {
                return event.player != player && event.player.isIn() && player.countCards("e", card => player.canUse(get.autoViewAs({ name: "sha" }, [card]), event.player, false));
            },
            async content(event, trigger, player) {
                var next = player.chooseToUse();
                next.set("openskilldialog", "王座：是否将装备区内的一张牌当作【杀】对" + get.translation(trigger.player) + "使用？");
                next.set("norestore", true);
                next.set("_backupevent", "reacgn_wangzuo_backup");
                next.set("custom", {
                    add: {},
                    replace: { window: function () { } },
                });
                next.backup("reacgn_wangzuo_backup");
                next.set("targetRequired", true);
                next.set("complexSelect", true);
                next.set("filterTarget", function (card, player, target) {
                    if (target != _status.event.sourcex && !ui.selected.targets.includes(_status.event.sourcex)) return false;
                    return lib.filter.targetEnabled.apply(this, arguments);
                });
                next.set("sourcex", trigger.player);
                next.set("addCount", false);
                next.logSkill = "reacgn_wangzuo";
            },
            subSkill: {
                backup: {
                    viewAs: {
                        name: "sha",
                    },
                    filterCard: true,
                    position: "e",
                    selectCard: 1,
                    check(card) {
                        return 6 - get.value(card);
                    },
                },
            },
        },
        //夜刀神天香
        reacgn_baonuegong: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            intro: {
                content: "expansion",
                markcount: "expansion",
            },
            onremove: function (player, skill) {
                var cards = player.getExpansions(skill);
                if (cards.length) player.loseToDiscardpile(cards);
            },
            locked: false,
            marktext: "武装",
            trigger: {
                player: "useCardAfter",
            },
            forced: true,
            filter: function (event, card, player) {
                if (ui.cardPile.childNodes.length <= 0) return false;
                if (!event.targets || !event.card) return false;
                if (event.card.name != 'sha') return false;
                return true;
            },
            content: function () {
                'step 0'
                //  var cards=ui.cardPile.firstChild;
                var cards = [];
                for (var i = 0; i < trigger.cards.length; i++) {
                    if (get.position(trigger.cards[i]) == 'd') {
                        cards.push(trigger.cards[i])
                    }
                }
                player.addToExpansion(cards, player, 'give').gaintag.add('reacgn_baonuegong');

                event.card = ui.cardPile.childNodes[0];
                if (!event.card) {
                    return;
                } else {
                    player.showCards(event.card);
                    player.showCards(cards);
                    player.reacgn_aosha = 'nai';
                    if (get.color(trigger.card) == get.color(event.card)) {

                        player.reacgn_aosha = 'sha';
                        player.chooseTarget(true, 1, get.prompt('reacgn_aosha'), function (card, player, target) {
                            return player.canUse({ name: 'sha' }, target);
                        }).ai = function (target) {
                            return get.effect(target, { name: 'sha' }, player);
                        };
                    }
                }
                "step 1"
                if (result.bool && player.reacgn_aosha == 'sha') {
                    var card = event.card;
                    card.name = 'sha';
                    card.nature = undefined;
                    player.useCard(event.card, result.targets, false);
                }
            },
        },
        reacgn_zhongyanzhijian: {
            nobracket: true,
            skillAnimation: "epic",
            animationColor: "fire",
            unique: true,
            mark: true,
            intro: {
                content: "limited",
            },
            init: function (player) {
                player.storage.reacgn_zhongyanzhijian = false;
            },
            enable: "phaseUse",
            audio: 'ext:约会大作战/audio:4',
            filter: function (event, player) {
                return player.getExpansions('reacgn_baonuegong').length > 0;
            },
            filterTarget: function (card, player, target) {
                return player.canUse({ name: 'sha', cards: player.getExpansions('reacgn_baonuegong') }, target);
            },
            content: function () {
                "step 0"
                player.awakenSkill('reacgn_zhongyanzhijian');
                player.useCard({ name: 'sha', nature: 'dark' }, target, player.getExpansions('reacgn_baonuegong'));

            },
            ai: {
                order: 1,
                result: {
                    target: function (player, target) {
                        if (player.hp > -1 || target.hp <= 2) {
                            return -get.effect(target, { name: 'sha' }, player);
                        }
                        return 0;
                    },
                },
            },

            group: ['reacgn_zhongyanzhijian_dmj'],
            subSkill: {
                dmj: {
                    trigger: { source: 'damageBegin' },
                    filter: function (event, card, player) {

                        return event.card && event.card.name == 'sha' && event.getParent(4).name == 'reacgn_baonuegong';
                    },
                    forced: true,
                    content: function () {
                        trigger.num = trigger.cards.length;
                    }

                },
            },
        },
        reacgn_fuling_tenka: {
            noAdd: true,
            noRemove: true,
            noDisabled: true,
            trigger: {
                player: "changeHp",
            },
            forced: true,
            filter: function (event, player) {
                return player.hp > 0 && player.name != 'db_reacgn_yatogamitooka' && player.name2 != 'db_reacgn_yatogamitooka';
            },
            audio: 'ext:约会大作战/audio:1',
            content: function () {
                'step 0'
                player.reinit('db_reacgn_yatogamitenka', 'db_reacgn_yatogamitooka', false);
            },
            group: ['reacgn_fuling_nodie', 'reacgn_fuling_notan', 'reacgn_fuling_dmj', 'reacgn_fuling_draw'],
        },
        reacgn_fuling_nodie: {
            trigger: {
                player: "dieBegin",
            },
            forced: true,
            forceDie: true,
            filter: function (event, player) {
                return player.hp <= 0;
            },
            content: function () {
                trigger.cancel();
            },
        },
        reacgn_fuling_notan: {
            trigger: {
                player: "phaseBefore",
            },
            forced: true,
            priority: 30,
            content: function () {
                trigger.untrigger();
                trigger.finish();
                player.phaseDraw();
                player.phaseUse();
            },

        },
        reacgn_fuling_dmj: {
            trigger: {
                player: "damageBefore",
            },
            audio: 'ext:约会大作战/audio:3',
            equipSkill: true,
            forced: true,
            filter: function (event, player) {
                return true;
            },
            content: function () {
                trigger.untrigger();
                trigger.finish();
                player.recover(trigger.num);
            },
            ai: {
                effect: {
                    target: function (card, player, target, current) {
                        if ((card.name == 'tao' || get.subtype(card) == 'kudamono')) return -3;
                    },
                },
            },
        },
        reacgn_fuling_draw: {
            trigger: {
                player: "phaseDrawBegin",
            },
            forced: true,
            content: function () {
                trigger.num += Math.floor(player.hp * -0.1);
            },

        },
        //崇宫澪
        reacgn_lunhuileyuan: {
            intro: {
                content: "expansion",
                markcount: "expansion",
            },
            onremove: function (player, skill) {
                var cards = player.getExpansions(skill);
                if (cards.length) player.loseToDiscardpile(cards);
            },
            locked: false,
            marktext: "乐园",
            nobracket: true,
            trigger: {
                global: "useCardAfter",
            },
            audio: 'ext:约会大作战/audio:1',
            filter: function (event, player) {
                var list = [];
                for (var i in player.storage) {
                    if (player.storage[i]) {
                        if (player.storage[i].cardid) {
                            list.push(player.storage[i]);
                        }
                        if (player.storage[i][0] && player.storage[i].length > 0) {
                            for (var j = 0; j < player.storage[i].length; j++) {
                                for (var k in player.storage[i][j]) {
                                    if (k == 'cardid' && player.storage[i][j][k] > 0) {
                                        list.push(player.storage[i][j]);
                                    }
                                    //k第i个标记的数组j的对象k。
                                }
                                //j第i个标记的数组下标j。
                            }
                            //i第i个标记。
                        }
                    }
                }
                for (var i = 0; i < player.getCards('x').length; i++) {
                    list.push(player.getCards('x')[i]);
                }
                for (var i = 0; i < list.length; i++) {
                    if (list[i].name == event.card.name) return true;
                }
                return false;
            },
            content: function () {
                "step 0"
                var list = [];
                for (var i in player.storage) {
                    if (player.storage[i]) {
                        if (player.storage[i].cardid) {
                            list.push(player.storage[i]);
                        }
                        if (player.storage[i][0] && player.storage[i].length > 0) {
                            for (var j = 0; j < player.storage[i].length; j++) {
                                for (var k in player.storage[i][j]) {
                                    if (k == 'cardid' && player.storage[i][j][k] > 0) {
                                        list.push(player.storage[i][j]);
                                    }
                                    //k第i个标记的数组j的对象k。
                                }
                                //j第i个标记的数组下标j。
                            }
                            //i第i个标记。
                        }
                    }
                }
                for (var i = 0; i < player.getCards('x').length; i++) {
                    list.push(player.getCards('x')[i]);
                }
                var card = list.randomGet();
                list.remove(card);
                player.gain(card, player, 'gain2');
                if (list.length > 0) {
                    trigger.player.gain(list.randomGet(), player, 'gain2');
                }
                "step 1"
            },
            mod: {
                maxHandcard: function (player, num) {
                    if (player.getExpansions('reacgn_lunhuileyuan') && player.getExpansions('reacgn_lunhuileyuan').length > 0) {
                        return num + player.getExpansions('reacgn_lunhuileyuan').length;
                    }
                },
            },
            group: ['reacgn_lunhuileyuan_gain'],
            subSkill: {
                gain: {
                    sub: true,
                    trigger: {
                        global: "loseAfter",
                    },
                    forced: true,
                    filter: function (event, player) {
                        if (event.type != 'discard') return false;
                        for (var i = 0; i < event.cards2.length; i++) {
                            if (get.position(event.cards2[i], true) == 'd') {
                                return true;
                            }
                        }
                        return false;
                    },
                    content: function () {
                        "step 0"
                        var cards = [];
                        for (var i = 0; i < trigger.cards2.length; i++) {
                            if (get.position(trigger.cards2[i], true) == 'd') {
                                cards.push(trigger.cards2[i]);
                            }
                        }
                        player.addToExpansion(cards, 'give').gaintag.add('reacgn_lunhuileyuan');
                        "step 1"
                    },
                },
            },
        },
        reacgn_wanxiangshengtang: {
            nobracket: true,
            trigger: {
                source: "damageEnd",
            },
            check: function (event, player) {
                var list = lib.characterSort.reacgn.reacgn_yuezhan;
                if (list.contains(event.player.name) || list.contains(event.player.name2)) return player.hp >= 1;
                return true;
            },
            audio: 'ext:约会大作战/audio:1',
            content: function () {
                'step 0'
                player.draw(2);
                if (trigger.player.isAlive()) {
                    player.chooseCard('he', true, '选择一张牌置于伤害来源的武将牌上称为“乐园”');
                }
                'step 1'
                if (trigger.player.isAlive()) {
                    if (result.bool && result.cards && result.cards.length) {
                        trigger.player.addToExpansion(result.cards, 'giveAuto', player).gaintag.add('reacgn_lunhuileyuan');
                    }
                }
            },
            group: ['reacgn_wanxiangshengtang_buff'],
            subSkill: {
                buff: {
                    trigger: {
                        global: "phaseBegin",
                    },
                    forced: true,
                    filter: function (event, player) {
                        return event.player != player && event.player.getExpansions('reacgn_lunhuileyuan') && event.player.getExpansions('reacgn_lunhuileyuan').length > 0;
                    },
                    content: function () {
                        if (player.maxHp - player.hp > 0) {
                            player.discardPlayerCard(trigger.player, player.maxHp - player.hp, 'he', true);
                        }
                        player.damage(trigger.player);
                        trigger.player.loseToDiscardpile(trigger.player.getExpansions('reacgn_lunhuileyuan'));
                    },
                },
            },
        },
        reacgn_wuxianzhizhi: {
            nobracket: true,
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                player: "dying",
            },
            skillAnimation: true,
            animationColor: "gray",
            filter(event, player) {
                var list = lib.characterSort.REACGN.reacgn_yuezhan;
                if (!_status.currentPhase || list.includes(_status.currentPhase.name) || list.includes(_status.currentPhase.name2)) return false;
                for (var i = 0; i < list.length; i++) {
                    for (var j = 0; j < game.players.length; j++) {
                        if (game.players[j].name == list[i] || game.players[j].name2 == list[i]) {
                            list.remove(list[i]);
                            i--;
                        }
                    }
                    for (var j = 0; j < game.dead.length; j++) {
                        if (game.dead[j].name == list[i] || game.dead[j].name2 == list[i]) {
                            list.remove(list[i]);
                            i--;
                        }
                    }
                }
                return list.length > 0;
            },
            async content(event, trigger, player) {
                await player.gainMaxHp();
                await player.recoverTo(player.maxHp);
                var list = lib.characterSort.REACGN.reacgn_yuezhan;
                game.log(list)
                for (var i = 0; i < list.length; i++) {
                    for (var j = 0; j < game.players.length; j++) {
                        if (game.players[j].name == list[i] || game.players[j].name2 == list[i]) {
                            list.remove(list[i]);
                            i--;
                        }
                    }
                    for (var j = 0; j < game.dead.length; j++) {
                        if (game.dead[j].name == list[i] || game.dead[j].name2 == list[i]) {
                            list.remove(list[i]);
                            i--;
                        }
                    }
                }
                const { result } = await player.chooseButton(true)
                    .set('createDialog', ['将' + get.translation(_status.currentPhase.name) + '的一张武将牌替换为一名角色', [list, 'character']])
                    .set('ai', function (button) {
                        return get.rank(button.link, true) - lib.character[button.link][2];
                    });
                if (result.bool) {
                    var targetName = _status.currentPhase.name;
                    if (!_status.currentPhase.name2) {
                        _status.currentPhase.reinit(targetName, result.links[0], false);
                        if (_status.characterlist) {
                            _status.characterlist.add(targetName);
                            _status.characterlist.remove(result.links[0]);
                            game.log(player, '将武将牌【', get.translation(targetName), '】换成了【', get.translation(result.links[0]), '】');
                        }
                    } else {
                        const { result: { control } } = await player.chooseControl(_status.currentPhase.name1, _status.currentPhase.name2)
                            .set('prompt', '请选择要更换的武将牌');
                        _status.currentPhase.reinit(result.control, result.links[0]);
                        if (_status.characterlist) {
                            _status.characterlist.add(result.control);
                            _status.characterlist.remove(result.links[0]);
                        }
                        game.log(player, '选择了将武将牌【', get.translation(result.control), '】换成【', get.translation(result.links[0]), '】');
                    }
                }
            },
        },
        //五河士道
        reacgn_jiushu: {
            enable: "phaseUse",
            audio: 'ext:约会大作战/audio:4',
            filter: function (event, player) {
                return player.getCards('he').length > 0 || player.hp > 0;
            },
            filterTarget: function (card, player, target) {
                return target.isDamaged() && target != player;
            },
            check: function (card, player, target) {
                if (target && ui.selected.cards.length < target.maxHp - target.hp) {
                    return 10 - get.value(card);
                }
                return false;
            },
            position: "he",
            selectCard: function () {
                return [0, Infinity];
            },
            filterCard: function (event, player) {
                return true;
            },
            usable: 1,
            content: function () {
                "step 0"
                if (cards.length == 0) {
                    var num = player.hp - 1;
                    if (player.countCards('hs', { name: ['tao', 'jiu'] })) {
                        num = player.hp;
                    }
                    var map = {};
                    var list = [];
                    for (var i = 1; i <= player.hp; i++) {
                        var cn = get.cnNumber(i, true);
                        map[cn] = i;
                        list.push(cn);
                    }
                    event.map = map;
                    player.chooseControl(list, function () {
                        return get.cnNumber(_status.event.goon, true);
                    }).set('prompt', '失去任意点体力').set('goon', num);
                }
                'step 1'
                var num = cards.length || event.map[result.control];
                if (event.map) {
                    player.loseHp(num);
                }
                target.recover(num);
            },
            ai: {
                threaten: 1.9,
                order: 9,
                result: {
                    player: function (player, target) {
                        if (target.maxHp - target.hp == 1 && player.hasSkill('reacgn_fengling') && lib.character[target.name] && lib.character[target.name][3] && lib.character[target.name][3][0] && !player.hasSkill(lib.character[target.name][3][0]) && ui.selected.cards.length == 1) return 10;
                        return 0;
                    },
                    target: function (player, target) {
                        if (target.hasSkill('boss_reacgn_fuling_tenka')) return -10;
                        if (!ui.selected.cards.length && player.hp - target.hp > 4) {
                            return 3;
                        }
                        if (ui.selected.cards.length <= target.maxHp - target.hp) {
                            return 3;
                        }
                        return 0;
                    },
                },
            },

            group: ['reacgn_jiushu_zl', 'reacgn_jiushu_hf'],
            subSkill: {
                zl: {
                    trigger: {
                        source: "damageBegin2",
                    },
                    filter: function (event, player) {
                        return player != event.player;
                    },
                    check: function (event, player) {
                        var att = get.attitude(player, event.player);
                        if (att > 0) return true;
                        return false;
                    },
                    logTarget: "player",
                    content: function () {
                        trigger.cancel();
                        trigger.player.recover(trigger.num);
                    },

                },
                hf: {
                    trigger: {
                        global: "recoverEnd",
                    },
                    filter: function (event, player, target) {
                        return event.source == player && player != event.player && player.hp > event.player.hp;
                    },
                    direct: true,
                    content: function () {
                        "step 0"
                        player.chooseControl('回复等量体力', '摸等量张牌', '取消').set('ai', function () {
                            var num = (player.maxHp - player.hp);
                            if (num >= trigger.num) return '回复等量体力';
                            if (num >= 2 && trigger.num <= 5) return '回复等量体力';
                            return '摸等量张牌';
                        }).set('prompt', '【救赎】：请选择一项');
                        "step 1"
                        if (result && result.control != '取消') {
                            player.logSkill('reacgn_jiushu');
                        }
                        if (result && result.control == '回复等量体力') {
                            player.recover(trigger.num);
                        }
                        if (result && result.control == '摸等量张牌') {
                            player.draw(trigger.num);
                        }

                    },

                },
            },
        },
        reacgn_fengling: {
            audio: 'ext:约会大作战/audio:2',
            trigger: {
                global: "recoverEnd",
            },
            filter: function (event, player, target) {
                return event.source == player && player != event.player && event.player.maxHp == event.player.hp && event.getParent(1).name == 'reacgn_jiushu';
            },
            forced: true,
            content: function () {
                "step 0"
                if (!player.reacgn_fengling) {
                    player.reacgn_fengling = [];
                }
                if (lib.character[trigger.player.name] && lib.character[trigger.player.name][3] && lib.character[trigger.player.name][3][0]) {
                    if (!player.hasSkill(lib.character[trigger.player.name][3][0])) {
                        player.reacgn_fengling.push(lib.character[trigger.player.name][3][0]);
                        player.addSkill(lib.character[trigger.player.name][3][0]);
                        player.addSkill('reacgn_fengling_buff');
                    }
                }
            },
        },
        reacgn_fengling_buff: {
            trigger: {
                global: "dieAfter",
            },
            forced: true,
            filter: function (event, player, target) {
                return player.reacgn_fengling;
            },
            content: function () {
                for (var i = 0; i < player.reacgn_fengling.length; i++) {
                    player.removeSkill(player.reacgn_fengling[i]);
                }
                player.reacgn_fengling = [];
            },
        },
    }
}

game.addGroup("reacgnmeng", "萌", "萌", { color: "#91040f" });
game.addGroup("reacgnling", "靈", "靈", { color: "#91040f" });